# power-assert-context-reducer-ast

> append AST into power-assert context

Latest version **1.2.0** (published 2018-06-12) · MIT license · 0 weekly downloads

## Install

```sh
npm install power-assert-context-reducer-ast
pnpm add power-assert-context-reducer-ast
yarn add power-assert-context-reducer-ast
bun add power-assert-context-reducer-ast
```

## Health

**Score 15/100 (F)** — status: abandoned.

Positive: no vulnerabilities.

Warnings: low downloads; no types; no esm support.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 1.2.0 |
| Published | 2018-06-12 |
| First published | 2016-05-31 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 5 |
| Unpacked size | 7.3 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 20 |
| Author | Takuto Wada |
| Maintainers | twada |
| Keywords | power-assert |

## Links

- npm: https://www.npmjs.com/package/power-assert-context-reducer-ast
- Repository: https://github.com/twada/power-assert-runtime
- Issues: https://github.com/twada/power-assert-runtime/issues
- npm.io page: https://npm.io/package/power-assert-context-reducer-ast

## Dependencies (5)

- [acorn](https://npm.io/package/acorn.md) ^5.0.0
- [core-js](https://npm.io/package/core-js.md) ^2.0.0
- [espurify](https://npm.io/package/espurify.md) ^1.6.0
- [estraverse](https://npm.io/package/estraverse.md) ^4.2.0
- [acorn-es7-plugin](https://npm.io/package/acorn-es7-plugin.md) ^1.0.12

## Recent versions

- 1.2.0 (latest) — 2018-06-12
- 1.1.2 — 2017-04-14
- 1.1.1 — 2016-11-10
- 1.1.0 — 2016-10-07
- 1.0.7 — 2016-07-01
- 1.0.2 — 2016-06-01
- 1.0.0 — 2016-05-31

## README

[![power-assert][power-assert-banner]][power-assert-url]

[![Build Status][travis-image]][travis-url]
[![NPM version][npm-image]][npm-url]
[![License][license-image]][license-url]


`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:
```js
{
    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:

```js
{
    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
---------------------------------------

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


AUTHOR
---------------------------------------
* [Takuto Wada](https://github.com/twada)


CONTRIBUTORS
---------------------------------------
* [Haoliang Gao (popomore)](https://github.com/popomore)


LICENSE
---------------------------------------
Licensed under the [MIT](https://github.com/twada/power-assert-runtime/blob/master/LICENSE) license.


[power-assert-url]: https://github.com/power-assert-js/power-assert
[power-assert-banner]: https://raw.githubusercontent.com/power-assert-js/power-assert-js-logo/master/banner/banner-official-fullcolor.png

[travis-url]: https://travis-ci.org/twada/power-assert-runtime
[travis-image]: https://secure.travis-ci.org/twada/power-assert-runtime.svg?branch=master

[npm-url]: https://npmjs.org/package/power-assert-context-reducer-ast
[npm-image]: https://badge.fury.io/js/power-assert-context-reducer-ast.svg

[license-url]: https://github.com/twada/power-assert-runtime/blob/master/LICENSE
[license-image]: https://img.shields.io/badge/license-MIT-brightgreen.svg

---
_Source: https://npm.io/package/power-assert-context-reducer-ast · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
