|  | 2 years ago | |
|---|---|---|
| .. | ||
| node_modules | 2 years ago | |
| README.md | 2 years ago | |
| index.js | 2 years ago | |
| package.json | 2 years ago | |
powerAssertContext reducer function to parse assertion expression at runtime.
Use this function when transpiler side does not add ast, tokens and visitorKeys at compile time.
Given powerAssertContext object, having structure below but does not have ast, tokens and visitorKeys, append them to output context.
input:
{
    source: {
        content: 'assert(foo === bar)',
        filepath: 'test/some_test.js',
        line: 1
    },
    args: [
        {
            value: false,
            events: [
                {
                    value: "FOO",
                    espath: "arguments/0/left"
                },
                {
                    value: "BAR",
                    espath: "arguments/0/right"
                },
                {
                    value: false,
                    espath: "arguments/0"
                }
            ]
        }
    ]
}
output:
{
    source: {
        content: 'assert(foo === bar)',
        filepath: 'test/some_test.js',
        line: 1,
        ast: '### JSON representation of AST nodes ###',
        tokens: '### JSON representation of AST tokens ###',
        visitorKeys: '### JSON representation of AST visitor keys ###'
    },
    args: [
        {
            value: false,
            events: [
                {
                    value: "FOO",
                    espath: "arguments/0/left"
                },
                {
                    value: "BAR",
                    espath: "arguments/0/right"
                },
                {
                    value: false,
                    espath: "arguments/0"
                }
            ]
        }
    ]
}
$ npm install --save-dev power-assert-context-reducer-ast
Licensed under the MIT license.