Skip to content

syntax-tree/mdast-util-assert

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

38 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

mdast-util-assert Build Coverage Downloads Chat

Assert MDAST nodes.

Installation

npm:

npm install mdast-util-assert

Usage

var assert = require('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

assert(node)

Assert that node is a valid MDAST node. If node has children, 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.

Contribute

See contributing.md in syntax-tree/mdast for ways to get started.

This organisation has a Code of Conduct. By interacting with this repository, organisation, or community you agree to abide by its terms.

License

MIT © Titus Wormer

Contributors 3

  •  
  •  
  •