{"name":"espower","description":"Power Assert feature instrumentor based on the ECMAScript AST","version":"1.3.2","author":{"name":"Takuto Wada","email":"takuto.wada@gmail.com","url":"http://github.com/twada"},"bugs":{"url":"http://github.com/power-assert-js/espower/issues"},"contributors":[{"name":"James Talmage","url":"https://github.com/jamestalmage"}],"dependencies":{"deep-equal":"^1.0.0","escallmatch":"^1.4.2","escodegen":"^1.7.0","espurify":"^1.3.0","estraverse":"^4.1.0","is-url":"^1.2.1","isarray":"^0.0.1","path-is-absolute":"^1.0.0","source-map":"^0.5.0","type-name":"^1.0.1","xtend":"^4.0.0"},"devDependencies":{"acorn":"^2.4.0","acorn-es7-plugin":"^1.0.7","amdefine":"^1.0.0","blanket":"^1.1.7","browserify":"^11.1.0","del":"^2.0.2","gulp":"^3.9.0","gulp-derequire":"^2.1.0","gulp-dereserve":"^0.2.1","gulp-jshint":"^1.11.2","gulp-mocha":"^2.1.3","gulp-mocha-phantomjs":"^0.10.1","gulp-util":"^3.0.6","gulp-webserver":"^0.9.1","jshint-stylish":"^2.0.1","licensify":"^2.0.1","mocha":"^2.3.3","mocha-lcov-reporter":"^1.0.0","package-json-versionify":"^1.0.2","through2":"^2.0.0","vinyl-source-stream":"^1.1.0"},"directories":{"lib":"./lib"},"files":["CHANGELOG.md","MIT-LICENSE.txt","README.md","gulpfile.js","index.js","build/espower.js","lib","package.json","test"],"homepage":"http://github.com/power-assert-js/espower","keywords":["power-assert","assert","assertion","test","testing","ecmascript","estree","ast"],"license":"MIT","main":"./index.js","repository":{"type":"git","url":"git+ssh://git@github.com/power-assert-js/espower.git"},"scripts":{"bower":"bower install --config.interactive=false","build":"npm prune && npm dedupe && gulp bundle","clean":"gulp clean","lint":"gulp lint","test":"npm run clean && npm run lint && npm run build && gulp test","unit":"gulp unit","watch":"gulp watch","coveralls":"gulp coverage && cat ./coverage.lcov | coveralls"},"gitHead":"f1c027bde45ff20f39c6b62f23df4ca6f2b2fae5","_id":"espower@1.3.2","_shasum":"7715f7516e576c857c06a8a88eb5e2bf2dd7824c","_from":".","_npmVersion":"3.9.3","_nodeVersion":"6.2.1","_npmUser":{"name":"twada","email":"takuto.wada@gmail.com"},"maintainers":[{"name":"twada","email":"takuto.wada@gmail.com"}],"dist":{"shasum":"7715f7516e576c857c06a8a88eb5e2bf2dd7824c","tarball":"http://registry-npm.ywwl.com/espower/download/espower-1.3.2.tgz","integrity":"sha512-Q7w86J/YVLehmZrgtdT/yVNd+WCDSflJYmvX+dDfp+qI/NHe6+265zPCXBvdfMRiLFLMGTHL1y7L4i7BeRx+Ig==","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEQCIBFOMzraxVnfdqxIgkPzGAyT7hirRUZAoywkUhPBRzBwAiBr2mE1tZW9GzERWGtdjl7vh9ggOAzh8zSKq+jP9TXsmQ=="}],"size":156468,"noattachment":false,"key":"/espower/-/espower-1.3.2.tgz"},"_npmOperationalInternal":{"host":"packages-12-west.internal.npmjs.com","tmp":"tmp/espower-1.3.2.tgz_1466594528035_0.940758696757257"},"readme":"espower\n================================\n\n[![Build Status][travis-image]][travis-url]\n[![NPM package][npm-image]][npm-url]\n[![Dependency Status][depstat-image]][depstat-url]\n[![Coverage Status][coverage-image]][coverage-url]\n[![Code Climate][codeclimate-image]][codeclimate-url]\n[![License][license-image]][license-url]\n\n\nPower Assert feature instrumentor based on the [ECMAScript AST](https://github.com/estree/estree).\n\n\nDESCRIPTION\n---------------------------------------\n`espower` is a core module of [power-assert](https://github.com/power-assert-js/power-assert) family. \n\n\n`espower` detects and manipulates assertion expression (JavaScript Code) in the form of ECMAScript AST defined in [The ESTree Spec](https://github.com/estree/estree) (formerly known as [Mozilla SpiderMonkey Parser API](https://developer.mozilla.org/en-US/docs/SpiderMonkey/Parser_API)), to instrument power-assert feature into returned new AST object. AST in, AST out. Since 0.11.0, `espower` can transform ES6 AST as well.\n\n\nPull-requests, issue reports and patches are always welcomed. See [power-assert](https://github.com/power-assert-js/power-assert) project for more documentation.\n\n\nCHANGELOG\n---------------------------------------\nSee [CHANGELOG](https://github.com/power-assert-js/espower/blob/master/CHANGELOG.md)\n\n\nAPI\n---------------------------------------\n\n### var modifiedAst = espower(ast, [options])\n\n| return type |\n|:------------|\n| `object`    |\n\n`espower` function manipulates `ast` then returns `modifiedAst` that is also an AST node object defined in [The ESTree Spec](https://github.com/estree/estree). `ast` will be manipulated directly and returned `modifiedAst` will be the same instance of `ast`.\n\n`espower` function throws `EspowerError` when\n\n* `ast` is already instrumented\n* `ast` does not contain location information\n* `options` argument is not valid\n\n\n### var visitor = espower.createVisitor(ast, [options])\n\n| return type |\n|:------------|\n| `object`    |\n\n`espower.createVisitor` generates visitor object to be used with `estraverse.replace`. Arguments are the same as `espower` function.\n\n\n#### ast\n\n| type     | default value |\n|:---------|:--------------|\n| `object` | N/A           |\n\n`ast` should be an AST node object defined in [The ESTree Spec](https://github.com/estree/estree).\n\n\n#### options\n\n| type     | default value |\n|:---------|:--------------|\n| `object` | (return value of `espower.defaultOptions()`) |\n\nConfiguration options. If not passed, default options will be used.\n\n\n#### options.patterns\n\n| type                | default value       |\n|:--------------------|:--------------------|\n| `Array` of `string` | objects shown below |\n\n```javascript\n[\n    'assert(value, [message])',\n    'assert.ok(value, [message])',\n    'assert.equal(actual, expected, [message])',\n    'assert.notEqual(actual, expected, [message])',\n    'assert.strictEqual(actual, expected, [message])',\n    'assert.notStrictEqual(actual, expected, [message])',\n    'assert.deepEqual(actual, expected, [message])',\n    'assert.notDeepEqual(actual, expected, [message])',\n    'assert.deepStrictEqual(actual, expected, [message])',\n    'assert.notDeepStrictEqual(actual, expected, [message])'\n]\n```\n\nTarget patterns for power assert feature instrumentation.\n\nIf callee name (for example, `assert.equal`) matches exactly and number of arguments is satisfied, then the assertion will be modified.\nDetection is done by [escallmatch](https://github.com/twada/escallmatch). Any arguments enclosed in bracket (for example, `[message]`) means optional parameters. Without bracket means mandatory parameters.\n\n\n#### options.ecmaVersion\n\n| type     | default value |\n|:---------|:--------------|\n| `number` | `2018`        |\n\nThe ECMAScript version to parse and analyze. Must be either 3, 5, 6 (2015), 2016, 2017, or 2018.\n\n\n#### options.sourceType\n\n| type     | default value |\n|:---------|:--------------|\n| `string` | `'module'`    |\n\nThe source type of the code. Must be either `\"script\"` or `\"module\"`.\n\n \n#### (optional) options.path\n\n| type     | default value |\n|:---------|:--------------|\n| `string` | N/A           |\n\nFilepath of `originalAst`. If passed, espower stores filepath information for reporting. If `options.path` is absolute and it conflicts with `options.sourceRoot` or `sourceRoot` in `options.sourceMap`, then filepath in power-assert output will be fall back on `basename` of `options.path`. This property is optional.\n\n\n#### (optional) options.sourceRoot\n\n| type     | default value |\n|:---------|:--------------|\n| `string` | N/A           |\n\nRoot filepath for target test files. Only works with `options.path` or `options.sourceMap`. If set, filepath in power-assert output will be relative from `options.sourceRoot`. When both `options.sourceRoot` and sourceMap's sourceRoot are given and both are absolute filepath, `options.sourceRoot` has precedence over sourceMap's sourceRoot. This property is optional.\n\n\n#### (optional) options.sourceMap\n\n| type                | default value |\n|:--------------------|:--------------|\n| `object` or `string`| N/A           |\n\nA raw (either as a string which can be JSON.parse'd, or an object) [SourceMap](https://github.com/mozilla/source-map/) associated with `originalAst`. This property is optional. If given, espower uses `options.sourceMap` to adjust information in the power-assert output.\n\n\n#### (optional) options.visitorKeys\n\n| type     | default value |\n|:---------|:--------------|\n| `object` | N/A           |\n\nVisitorKeys for AST traversal. See [estraverse.VisitorKeys](https://github.com/estools/estraverse/blob/4.0.0/estraverse.js#L217-L288) and [babel.types.VISITOR_KEYS](https://github.com/babel/babel/blob/v5.1.13/src/babel/types/visitor-keys.json).\n\n\n### var options = espower.defaultOptions();\n\nReturns default options object for `espower` function. In other words, returns\n\n```javascript\n{\n    ecmaVersion: 2018,\n    sourceType: 'module',\n    patterns: [\n        'assert(value, [message])',\n        'assert.ok(value, [message])',\n        'assert.equal(actual, expected, [message])',\n        'assert.notEqual(actual, expected, [message])',\n        'assert.strictEqual(actual, expected, [message])',\n        'assert.notStrictEqual(actual, expected, [message])',\n        'assert.deepEqual(actual, expected, [message])',\n        'assert.notDeepEqual(actual, expected, [message])',\n        'assert.deepStrictEqual(actual, expected, [message])',\n        'assert.notDeepStrictEqual(actual, expected, [message])'\n    ]\n}\n```\n\n\nEXAMPLE\n---------------------------------------\n\nFor given test file `example_test.js` below,\n\n```javascript\nvar assert = require('power-assert');\nvar truthy = 'true';\nvar falsy = 'false';\nassert(falsy);\nassert.equal(truthy, falsy);\n```\n\nApply `espower` then generate modified code to console,\n\n```javascript\nvar espower = require('espower');\nvar esprima = require('esprima');\nvar escodegen = require('escodegen');\nvar fs = require('fs');\nvar path = require('path');\n\nvar filepath = path.join(__dirname, 'example_test.js');\nvar jsAst = esprima.parse(fs.readFileSync(filepath), {tolerant: true, loc: true, tokens: true});\nvar modifiedAst = espower(jsAst, {path: filepath, sourceRoot: __dirname});\n\nconsole.log(escodegen.generate(modifiedAst));\n```\n\nOutput:\n\n```javascript\nvar _PowerAssertRecorder1 = function () {\n    function PowerAssertRecorder() {\n        this.captured = [];\n    }\n    PowerAssertRecorder.prototype._capt = function _capt(value, espath) {\n        this.captured.push({\n            value: value,\n            espath: espath\n        });\n        return value;\n    };\n    PowerAssertRecorder.prototype._expr = function _expr(value, source) {\n        var capturedValues = this.captured;\n        this.captured = [];\n        return {\n            powerAssertContext: {\n                value: value,\n                events: capturedValues\n            },\n            source: source\n        };\n    };\n    return PowerAssertRecorder;\n}();\nvar _rec1 = new _PowerAssertRecorder1();\nvar _rec2 = new _PowerAssertRecorder1();\nvar _rec3 = new _PowerAssertRecorder1();\nvar assert = require('power-assert');\nvar truthy = 'true';\nvar falsy = 'false';\nassert(_rec1._expr(_rec1._capt(falsy, 'arguments/0'), {\n    content: 'assert(falsy)',\n    filepath: 'example_test.js',\n    line: 4\n}));\nassert.equal(_rec2._expr(_rec2._capt(truthy, 'arguments/0'), {\n    content: 'assert.equal(truthy, falsy)',\n    filepath: 'example_test.js',\n    line: 5\n}), _rec3._expr(_rec3._capt(falsy, 'arguments/1'), {\n    content: 'assert.equal(truthy, falsy)',\n    filepath: 'example_test.js',\n    line: 5\n}));\n```\n\n\nINSTALL\n---------------------------------------\n\n### via npm\n\nInstall\n\n    $ npm install --save-dev espower\n\n\nOUR SUPPORT POLICY\n---------------------------------------\n\nWe support Node under maintenance. In other words, we stop supporting old Node version when [their maintenance ends](https://github.com/nodejs/LTS).\n\nThis means that any other environment is not supported.\n\nNOTE: If espower works in any of the unsupported environments, it is purely coincidental and has no bearing on future compatibility. Use at your own risk.\n\n\nAUTHOR\n---------------------------------------\n* [Takuto Wada](https://github.com/twada)\n\n\nCONTRIBUTORS\n---------------------------------------\n* [James Talmage (jamestalmage)](https://github.com/jamestalmage)\n\n\nLICENSE\n---------------------------------------\nLicensed under the [MIT](https://github.com/power-assert-js/espower/blob/master/MIT-LICENSE.txt) license.\n\n\n[npm-url]: https://npmjs.org/package/espower\n[npm-image]: https://badge.fury.io/js/espower.svg\n\n[travis-url]: https://travis-ci.org/power-assert-js/espower\n[travis-image]: https://secure.travis-ci.org/power-assert-js/espower.svg?branch=master\n\n[depstat-url]: https://gemnasium.com/power-assert-js/espower\n[depstat-image]: https://gemnasium.com/power-assert-js/espower.svg\n\n[license-url]: https://github.com/power-assert-js/espower/blob/master/MIT-LICENSE.txt\n[license-image]: https://img.shields.io/badge/license-MIT-brightgreen.svg?style=flat\n\n[codeclimate-url]: https://codeclimate.com/github/power-assert-js/espower\n[codeclimate-image]: https://codeclimate.com/github/power-assert-js/espower/badges/gpa.svg\n\n[coverage-url]: https://coveralls.io/r/power-assert-js/espower?branch=master\n[coverage-image]: https://coveralls.io/repos/power-assert-js/espower/badge.svg?branch=master\n","publish_time":1466594530523,"_cnpm_publish_time":1466594530523,"dist-tags":{"latest":"2.1.2"}}