1.2.0 • Published 6 years ago

power-assert-context-reducer-ast v1.2.0

Weekly downloads
150,431
License
MIT
Repository
github
Last release
6 years ago

power-assert

Build Status NPM version License

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.

API

var appendAst = require('power-assert-context-reducer-ast');

var appendedContext = appendAst(powerAssertContext);

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"
                }
            ]
        }
    ]
}

INSTALL

$ npm install --save-dev power-assert-context-reducer-ast

AUTHOR

CONTRIBUTORS

LICENSE

Licensed under the MIT license.

1.2.0

6 years ago

1.1.2

7 years ago

1.1.1

7 years ago

1.1.0

8 years ago

1.0.7

8 years ago

1.0.2

8 years ago

1.0.0

8 years ago