Project: syntax-tree/mdast-util-assert

Package: mdast-util-assert@4.0.0

  1. Dependents: 4
  2. mdast utility to assert trees
  1. util 144
  2. utility 140
  3. unist 127
  4. mdast 83
  5. mdast-util 31
  6. check 11
  7. test 6
  8. assert 4


Build Coverage Downloads Size Sponsors Backers Chat

mdast utility to assert trees.


This package is ESM only: Node 12+ is needed to use it and it must be imported instead of required.


npm install mdast-util-assert


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' }`


This package exports the following identifiers: assert, parent, literal, _void, wrap. There is no default export.


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.


Use of mdast-util-assert does not involve hast so there are no openings for cross-site scripting (XSS) attacks.


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.


MIT © Titus Wormer