unified

Project: syntax-tree/hast-util-assert

Package: hast-util-assert@2.0.0

  1. Dependencies: 3·Dependents: 0
  2. hast utility to assert nodes
  1. util 106
  2. utility 104
  3. unist 97
  4. hast 59
  5. hast-util 40
  6. check 9
  7. test 6
  8. assert 4

hast-util-assert

Build Coverage Downloads Size Sponsors Backers Chat

hast utility to assert trees.

Install

npm:

npm install hast-util-assert

Use

var assert = require('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: [] }`

API

assert(tree)

Assert that the given tree is a valid hast tree. If tree is a parent, all children will be asserted as well.

The assert.parent, assert.text, assert.void, and assert.wrap methods from unist-util-assert are also included.

Security

hast-util-assert does not change the syntax tree so there are no openings for cross-site scripting (XSS) attacks.

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.

License

MIT © Titus Wormer