hast utility to assert trees.
This package is ESM only:
Node 12+ is needed to use it and it must be import
ed instead of require
d.
npm:
npm install hast-util-assert
import {assert} from 'hast-util-assert'
assert({type: 'root', children: []})
assert({type: 'element', tagName: 'a', properties: {}, children: []})
// All OK.
assert({children: []})
// AssertionError: node should have a type: `{ children: [] }`
assert({type: 'element', properties: {}, children: []})
// AssertionError: `element` should have a `tagName`: `{ type: 'element', properties: {}, children: [] }`
This package exports the following identifiers: assert
, parent
, literal
,
_void
, wrap
.
There is no default export.
Assert that the given tree
is a valid hast tree.
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.
hast-util-assert
does not change the syntax tree so there are no openings for
cross-site scripting (XSS) attacks.
unist-util-assert
— check unist nodesmdast-util-assert
— check mdast nodesnlcst-test
— check nlcst nodes
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.