{"name":"espower","description":"Power Assert feature instrumentor based on the Mozilla JavaScript AST","version":"0.9.1","author":{"name":"Takuto Wada","email":"takuto.wada@gmail.com","url":"http://github.com/twada"},"bugs":{"url":"http://github.com/twada/espower/issues"},"dependencies":{"clone":"~0.1.18","escallmatch":"~0.3.1","escodegen":"~1.3.3","espurify":"~0.1.3","estraverse":"~1.5.1","source-map":"~0.1.38","type-name":"~1.0.0","xtend":"~4.0.0"},"devDependencies":{"blanket":"~1.1.6","browserify":"~5.11.2","del":"~0.1.2","esprima":"~1.2.2","gulp":"~3.8.8","gulp-derequire":"~1.1.0","gulp-mocha":"~1.1.0","gulp-mocha-phantomjs":"~0.5.0","gulp-util":"~3.0.1","gulp-webserver":"~0.6.0","mocha":"~1.21.4","mocha-lcov-reporter":"~0.0.1","through2":"~1.1.1","vinyl-source-stream":"~0.1.1"},"directories":{"lib":"./lib"},"files":["CHANGELOG.md","MIT-LICENSE.txt","README.md","gulpfile.js","index.js","lib","package.json","test"],"homepage":"http://github.com/twada/espower","keywords":["power-assert","test","assert","testing","ecmascript","ast"],"license":{"type":"MIT","url":"https://github.com/twada/espower/blob/master/MIT-LICENSE.txt"},"main":"./index.js","repository":{"type":"git","url":"http://github.com/twada/espower.git"},"scripts":{"bower":"bower install --config.interactive=false","test":"gulp test","coveralls":"gulp coverage && cat ./coverage.lcov | coveralls"},"gitHead":"ef3d33ea6761b6b8ed8917b2fbe4e101d79f7466","_id":"espower@0.9.1","_shasum":"63c9c431ba4a9fa73ce067cf4178ce645362b5d4","_from":".","_npmVersion":"1.4.27","_npmUser":{"name":"twada","email":"takuto.wada@gmail.com"},"maintainers":[{"name":"twada","email":"takuto.wada@gmail.com"}],"dist":{"shasum":"63c9c431ba4a9fa73ce067cf4178ce645362b5d4","tarball":"http://registry-npm.ywwl.com/espower/download/espower-0.9.1.tgz","integrity":"sha512-18w/xi/G6SvSdXENLDwmh+phdQ6iu4FuaISu/9yE0bwFRK1jvEakI7PADmcf1aBEg9MTH2vcEuhn0ZRxNMkNMA==","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEYCIQDohS3m8PiyN25+m5nIQETu+Ov6pOuUq9odZ+hXfMQoLwIhAO146PohOAARI5d/HxJwLVuCVUWklPacQ0TW/JYdcTvY"}],"size":14288,"noattachment":false,"key":"/espower/-/espower-0.9.1.tgz"},"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":1410731342432,"_cnpm_publish_time":1410731342432,"dist-tags":{"latest":"2.1.2"}}