Package Exports
- mdast-util-assert
This package does not declare an exports field, so the exports above have been automatically detected and optimized by JSPM instead. If any package subpath is missing, it is recommended to post an issue to the original package (mdast-util-assert) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.
Readme
mdast-util-assert
mdast utility to assert trees.
Install
This package is ESM only:
Node 12+ is needed to use it and it must be imported instead of required.
npm:
npm install mdast-util-assertUse
import {assert} from 'mdast-util-assert'
assert({type: 'root', children: []})
assert({type: 'break'})
assert({type: 'listItem', checked: true, children: []})
// All OK.
assert({children: []})
// AssertionError: node should have a type: `{ children: [] }`
assert({type: 'paragraph', value: 'foo'})
// AssertionError: parent should have children: `{ type: 'paragraph', value: 'foo' }`API
This package exports the following identifiers: assert, parent, literal,
_void, wrap.
There is no default export.
assert(node)
Assert that tree is a valid mdast node.
If tree is a parent, all children will be asserted as well.
The parent, literal, _void, and wrap methods from
unist-util-assert are also included.
Security
Use of mdast-util-assert does not involve hast so there are no
openings for cross-site scripting (XSS) attacks.
Related
unist-util-assert— check unist nodeshast-util-assert— check hast nodesnlcst-test— check nlcst nodes
Contribute
See contributing.md in syntax-tree/.github for ways to get
started.
See support.md for ways to get help.
This project has a code of conduct. By interacting with this repository, organization, or community you agree to abide by its terms.