Skip to content

syntax-tree/hast-util-assert

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

43 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

hast-util-assert

Build Coverage Downloads Size Sponsors Backers Chat

hast utility to assert trees.

Install

npm:

npm install hast-util-assert

Usage

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.

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, organisation, or community you agree to abide by its terms.

License

MIT © Titus Wormer