nlcst-test
    TypeScript icon, indicating that this package has built-in type declarations

    3.0.0 • Public • Published

    nlcst-test

    Build Coverage Downloads Size Sponsors Backers Chat

    nlcst utility to assert trees.

    Install

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

    npm:

    npm install nlcst-test

    Use

    import {assert} from 'nlcst-test'
    
    assert({type: 'RootNode', children: []})
    assert({type: 'SourceNode', value: 'fn()'})
    assert({type: 'WordNode', children: [{type: 'TextNode', value: 'Hi'}]})
    // All OK.
    
    assert({children: []})
    // AssertionError: node should have a type: `{ children: [] }`
    
    assert({type: 'WordNode', value: 'foo'})
    // AssertionError: parent should have children: `{ type: 'WordNode', value: 'foo' }`

    API

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

    assert(tree)

    Assert that tree is a valid nlcst node. If tree is a parent, all children will be asserted as well.

    The other methods come from unist-util-assert.

    Related

    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

    Install

    npm i nlcst-test

    DownloadsWeekly Downloads

    14

    Version

    3.0.0

    License

    MIT

    Unpacked Size

    9.37 kB

    Total Files

    5

    Last publish

    Collaborators

    • avatar
    • avatar