{"name":"espower","description":"Power Assert feature instrumentor based on the ECMAScript AST","version":"2.1.2","author":{"name":"Takuto Wada","email":"takuto.wada@gmail.com","url":"https://github.com/twada"},"bugs":{"url":"https://github.com/power-assert-js/espower/issues"},"contributors":[{"name":"James Talmage","url":"https://github.com/jamestalmage"}],"dependencies":{"array-find":"^1.0.0","escallmatch":"^1.5.0","escodegen":"^1.7.0","escope":"^3.3.0","espower-location-detector":"^1.0.0","espurify":"^1.3.0","estraverse":"^4.1.0","source-map":"^0.5.0","type-name":"^2.0.0"},"devDependencies":{"acorn":"^5.0.0","acorn-es7-plugin":"^1.0.14","esprima":"^4.0.0","jshint":"^2.9.2","mocha":"^5.0.0","nyc":"^13.1.0","rimraf":"^2.6.3"},"directories":{"lib":"./lib"},"homepage":"https://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+https://github.com/power-assert-js/espower.git"},"scripts":{"preversion":"npm test","clean":"rimraf ./coverage","lint":"jshint index.js lib","gen":"node gen.js","test":"npm run lint && npm run gen && npm run test:unit","test:unit":"mocha --reporter dot","test:cov":"nyc --reporter=lcovonly npm run test:unit","coveralls":"npm run test:cov && cat ./coverage/lcov.info | coveralls"},"gitHead":"55d8c9d110b260763be27b57a593192386a28d53","_id":"espower@2.1.2","_npmVersion":"6.4.1","_nodeVersion":"10.11.0","_npmUser":{"name":"twada","email":"takuto.wada@gmail.com"},"dist":{"integrity":"sha512-2qa3aEFtcgPB782jTKDPu82hOdw8+zJsWdOn12Tey8XlexHTqsYUIdLC2B7cUECENXly0vZblH1CEZcqttPNjw==","shasum":"824f88788f9fedf4cf0f928f5e11bb907ce9b918","tarball":"http://registry-npm.ywwl.com/espower/download/espower-2.1.2.tgz","fileCount":14,"unpackedSize":64088,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.4\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJcN+xBCRA9TVsSAnZWagAAJ/AQAJYrII4rFqFEUz/D37Qq\nHsXWdS/Cf6JEb8hQd/ok5xJsICigkfWifpgyumlg2lF+Mqi9sleiSxixVCIu\nkS3vwYW3CmN/Dq0Hr2RTIs2REuQF8vwFEhCrwMvuoZBHXY0tpHd38PVhDGoi\ntGBlpjS83yxf7iOKYentXWTxQxDuzrIPIft9v1Y/dgz1GYpQLIgni6d2O8Di\n4kCmYgg/P3kb9lVo+z49Wd47lKXyaesI3HdTcON0sCskx3YcWL0nPbSq7w/U\nFysM8ShBuC5JMsa6s/G7wWg77e6B0ZZ+mJm7n5arkgA/3ihLSYeHs11Hd4Uk\nI6lRgfDo+ncdXNSUdGmsilWo8E/Y34NxpczDBltknCoMaHIf1I1jC7EgRuqU\nO7Gkj8FlIuwU1ZA4DD1NhKc1iKeW1IgKowmXfiJMqrkFhmkAIrEKhOfOXwA3\nIfN0zXxrgIhhxBbz1srDAxKeG0onDhC03COQqIgzZ25IajfaHPASqMTOaUsH\n5tEwNf/dBoIxZErii7/bifSfolEDKiG8EcXcniR7ti5dtirrJ6fAcmhkw1KT\nZO13fRZcBxQGUMQ+IWSLvoh1c4g2CMFJ4FqYfIGsczcihARtjQ3CnBvJN9lB\nwidyt0KfU119JRWi7id0Xei0ntWUpxQGCPHo7Aru0OJ5mcmgW+D2+g6uRNYd\nTgYr\r\n=qNaB\r\n-----END PGP SIGNATURE-----\r\n","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEQCIGwJzDJ9zCgtc9SRGJ7xY9O4A0An+dAB9soPjCckwCM6AiBg7RtvXMRHwOPNUOgg3vTrgIK6ycmJC6EkyNTZX+L80A=="}],"size":14195,"noattachment":false,"key":"/espower/-/espower-2.1.2.tgz"},"maintainers":[{"name":"twada","email":"takuto.wada@gmail.com"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/espower_2.1.2_1547168833172_0.42452129388221405"},"_hasShrinkwrap":false,"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":1547168833366,"_cnpm_publish_time":1547168833366,"dist-tags":{"latest":"2.1.2"}}