pax_global_header00006660000000000000000000000064134235453570014525gustar00rootroot0000000000000052 comment=1c3837acfb68162faa6ab417ad0139dd20af50b2 detective-5.2.0/000077500000000000000000000000001342354535700135055ustar00rootroot00000000000000detective-5.2.0/.gitignore000066400000000000000000000000411342354535700154700ustar00rootroot00000000000000node_modules bench/src/jquery.js detective-5.2.0/.npmignore000066400000000000000000000000241342354535700155000ustar00rootroot00000000000000bench/src/jquery.js detective-5.2.0/.npmrc000066400000000000000000000000231342354535700146200ustar00rootroot00000000000000package-lock=false detective-5.2.0/.travis.yml000066400000000000000000000003151342354535700156150ustar00rootroot00000000000000language: node_js node_js: - "11" - "10" - "9" - "8" - "6" - "4" - "iojs" - "0.12" - "0.10" - "0.8" sudo: false before_install: - 'nvm install-latest-npm' matrix: fast_finish: true detective-5.2.0/CHANGELOG.md000066400000000000000000000016241342354535700153210ustar00rootroot00000000000000# detective Change Log All notable changes to this project will be documented in this file. This project adheres to [Semantic Versioning](http://semver.org/). ## 5.2.0 - 2019-01-28 * Use acorn-node's option defaults, adds support for new ES features (https://github.com/browserify/detective/pull/81) ## 5.1.0 - 2018-02-28 * Use acorn-node parser, which matches latest Node syntax support (https://github.com/browserify/detective/pull/78) * Add basic cli: `detective index.js` outputs dependency names (https://github.com/browserify/detective/pull/51) ## 5.0.2 - 2018-01-06 * Extend support back to 0.8 until we can determine a LTS plan. ## 5.0.1 - 2018-01-02 * Add engines field set to `>=4.0.0`. ## 5.0.0 - 2018-01-02 * Fix: Don't crash on files with the spread operator (https://github.com/browserify/detective/pull/75) * Breaking: Drop support for node 0.12 (https://github.com/browserify/detective/pull/75) detective-5.2.0/LICENSE000066400000000000000000000020611342354535700145110ustar00rootroot00000000000000This software is released under the MIT license: Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. detective-5.2.0/bench/000077500000000000000000000000001342354535700145645ustar00rootroot00000000000000detective-5.2.0/bench/detect.js000066400000000000000000000003141342354535700163700ustar00rootroot00000000000000var detective = require('../'); var fs = require('fs'); var src = fs.readFileSync(__dirname + '/src/jquery.js', 'utf8'); var t0 = Date.now(); var requires = detective(src); console.log(Date.now() - t0); detective-5.2.0/bench/esprima_v_acorn.txt000066400000000000000000000002521342354535700204730ustar00rootroot00000000000000esprima: $ for i in {1..5}; do node detect.js; done 704 702 704 704 697 acorn: $ for i in {1..5}; do node detect.js; done 555 552 585 549 583 detective-5.2.0/bin/000077500000000000000000000000001342354535700142555ustar00rootroot00000000000000detective-5.2.0/bin/detective.js000077500000000000000000000004451342354535700165750ustar00rootroot00000000000000#!/usr/bin/env node var detective = require('../'); var argv = require('minimist')(process.argv.slice(2)); var fs = require('fs'); argv._.forEach(function(file) { var src = fs.readFileSync(file, 'utf8'); var requires = detective(src, argv); console.log(requires.join('\n')); }); detective-5.2.0/example/000077500000000000000000000000001342354535700151405ustar00rootroot00000000000000detective-5.2.0/example/strings.js000066400000000000000000000002511342354535700171650ustar00rootroot00000000000000var detective = require('../'); var fs = require('fs'); var src = fs.readFileSync(__dirname + '/strings_src.js'); var requires = detective(src); console.dir(requires); detective-5.2.0/example/strings_src.js000066400000000000000000000001021342354535700200270ustar00rootroot00000000000000var a = require('a'); var b = require('b'); var c = require('c'); detective-5.2.0/index.js000066400000000000000000000052051342354535700151540ustar00rootroot00000000000000var acorn = require('acorn-node'); var walk = require('acorn-node/walk'); var defined = require('defined'); var requireRe = /\brequire\b/; function parse (src, opts) { if (!opts) opts = {}; var acornOpts = { ranges: defined(opts.ranges, opts.range), locations: defined(opts.locations, opts.loc), allowReserved: defined(opts.allowReserved, true), allowImportExportEverywhere: defined(opts.allowImportExportEverywhere, false) }; // Use acorn-node's defaults for the rest. if (opts.ecmaVersion != null) acornOpts.ecmaVersion = opts.ecmaVersion; if (opts.sourceType != null) acornOpts.sourceType = opts.sourceType; if (opts.allowHashBang != null) acornOpts.allowHashBang = opts.allowHashBang; if (opts.allowReturnOutsideFunction != null) acornOpts.allowReturnOutsideFunction = opts.allowReturnOutsideFunction; return acorn.parse(src, acornOpts); } var exports = module.exports = function (src, opts) { return exports.find(src, opts).strings; }; exports.find = function (src, opts) { if (!opts) opts = {}; var word = opts.word === undefined ? 'require' : opts.word; if (typeof src !== 'string') src = String(src); var isRequire = opts.isRequire || function (node) { return node.callee.type === 'Identifier' && node.callee.name === word ; }; var modules = { strings : [], expressions : [] }; if (opts.nodes) modules.nodes = []; var wordRe = word === 'require' ? requireRe : RegExp('\\b' + word + '\\b'); if (!wordRe.test(src)) return modules; var ast = parse(src, opts.parse); function visit(node, st, c) { var hasRequire = wordRe.test(src.slice(node.start, node.end)); if (!hasRequire) return; walk.base[node.type](node, st, c); if (node.type !== 'CallExpression') return; if (isRequire(node)) { if (node.arguments.length) { var arg = node.arguments[0]; if (arg.type === 'Literal') { modules.strings.push(arg.value); } else if (arg.type === 'TemplateLiteral' && arg.quasis.length === 1 && arg.expressions.length === 0) { modules.strings.push(arg.quasis[0].value.raw); } else { modules.expressions.push(src.slice(arg.start, arg.end)); } } if (opts.nodes) modules.nodes.push(node); } } walk.recursive(ast, null, { Statement: visit, Expression: visit }); return modules; }; detective-5.2.0/package.json000066400000000000000000000013111342354535700157670ustar00rootroot00000000000000{ "name": "detective", "description": "find all require() calls by walking the AST", "version": "5.2.0", "author": { "name": "James Halliday", "email": "mail@substack.net", "url": "http://substack.net" }, "bin": "bin/detective.js", "dependencies": { "acorn-node": "^1.6.1", "defined": "^1.0.0", "minimist": "^1.1.1" }, "devDependencies": { "tap": "^10.7.3" }, "engines": { "node": ">=0.8.0" }, "keywords": [ "analyze", "ast", "require", "source" ], "license": "MIT", "main": "index.js", "repository": { "type": "git", "url": "git://github.com/browserify/detective.git" }, "scripts": { "test": "tap test/*.js" } } detective-5.2.0/readme.markdown000066400000000000000000000032421342354535700165070ustar00rootroot00000000000000# detective find all calls to `require()` by walking the AST [![build status](https://secure.travis-ci.org/browserify/detective.png)](http://travis-ci.org/browserify/detective) # example ## strings strings_src.js: ``` js var a = require('a'); var b = require('b'); var c = require('c'); ``` strings.js: ``` js var detective = require('detective'); var fs = require('fs'); var src = fs.readFileSync(__dirname + '/strings_src.js'); var requires = detective(src); console.dir(requires); ``` output: ``` $ node examples/strings.js [ 'a', 'b', 'c' ] ``` # methods ``` js var detective = require('detective'); ``` ## detective(src, opts) Give some source body `src`, return an array of all the `require()` calls with string arguments. The options parameter `opts` is passed along to `detective.find()`. ## var found = detective.find(src, opts) Give some source body `src`, return `found` with: * `found.strings` - an array of each string found in a `require()` * `found.expressions` - an array of each stringified expression found in a `require()` call * `found.nodes` (when `opts.nodes === true`) - an array of AST nodes for each argument found in a `require()` call Optionally: * `opts.word` - specify a different function name instead of `"require"` * `opts.nodes` - when `true`, populate `found.nodes` * `opts.isRequire(node)` - a function returning whether an AST `CallExpression` node is a require call * `opts.parse` - supply options directly to [acorn](https://npmjs.org/package/acorn) with some support for esprima-style options `range` and `loc` * `opts.ecmaVersion` - default: 9 # install With [npm](https://npmjs.org) do: ``` npm install detective ``` # license MIT detective-5.2.0/test/000077500000000000000000000000001342354535700144645ustar00rootroot00000000000000detective-5.2.0/test/both.js000066400000000000000000000015131342354535700157560ustar00rootroot00000000000000var test = require('tap').test; var detective = require('../'); var fs = require('fs'); var src = fs.readFileSync(__dirname + '/files/both.js'); test('both', function (t) { var modules = detective.find(src); t.deepEqual(modules.strings, [ 'a', 'b' ]); t.deepEqual(modules.expressions, [ "'c' + x", "'d' + y" ]); t.notOk(modules.nodes, 'has no nodes'); t.end(); }); test('both with nodes specified in opts', function (t) { var modules = detective.find(src, { nodes: true }); t.deepEqual(modules.strings, [ 'a', 'b' ]); t.deepEqual(modules.expressions, [ "'c' + x", "'d' + y" ]); t.deepEqual( modules.nodes.map(function (n) { var arg = n.arguments[0]; return arg.value || arg.left.value; }), [ 'a', 'b', 'c', 'd' ], 'has a node for each require'); t.end(); }); detective-5.2.0/test/chained.js000066400000000000000000000003711342354535700164160ustar00rootroot00000000000000var test = require('tap').test; var detective = require('../'); var fs = require('fs'); var src = fs.readFileSync(__dirname + '/files/chained.js'); test('chained', function (t) { t.deepEqual(detective(src), [ 'c', 'b', 'a' ]); t.end(); }); detective-5.2.0/test/complicated.js000066400000000000000000000033541342354535700173130ustar00rootroot00000000000000var test = require('tap').test; var detective = require('../'); var sources = [ 'require("a")', "require('a')", 'require(`a`)', ';require("a")', ' require("a")', 'void require("a")', '+require("a")', '!require("a")', '/*comments*/require("a")', '(require("a"))', 'require/*comments*/("a")', ';require/*comments*/("a")', ' require/*comments*/("a")', 'void require/*comments*/("a")', '+require/*comments*/("a")', '!require/*comments*/("a")', '/*comments*/require/*comments*/("a")', '(require/*comments*/("a"))', 'require /*comments*/ ("a")', ';require /*comments*/ ("a")', ' require /*comments*/ ("a")', 'void require /*comments*/ ("a")', '+require /*comments*/ ("a")', '!require /*comments*/ ("a")', ' /*comments*/ require /*comments*/ ("a")', '(require /*comments*/ ("a"))', 'require /*comments*/ /*more comments*/ ("a")', ';require /*comments*/ /*more comments*/ ("a")', ' require /*comments*/ /*more comments*/ ("a")', 'void require /*comments*/ /*more comments*/ ("a")', '+require /*comments*/ /*more comments*/ ("a")', '!require /*comments*/ /*more comments*/ ("a")', ' /*comments*/ /*more comments*/ require /*comments*/ /*more comments*/ ("a")', '(require /*comments*/ /*more comments*/ ("a"))', 'require//comments\n("a")', ';require//comments\n("a")', ' require//comments\n("a")', 'void require//comments\n("a")', '+require//comments\n("a")', '!require//comments\n("a")', ' require//comments\n("a")', '(require//comments\n("a"))' ]; test('complicated', function (t) { t.plan(sources.length); sources.forEach(function(src) { t.deepEqual(detective(src), [ 'a' ]); }); }); detective-5.2.0/test/es2019.js000066400000000000000000000010361342354535700157450ustar00rootroot00000000000000var test = require('tap').test; var detective = require('../'); var fs = require('fs'); test('es2019 - for-await', function (t) { var src = fs.readFileSync(__dirname + '/files/for-await.js'); t.doesNotThrow(detective.bind(detective, src), 'Files with `for await()` do not throw') t.end(); }); test('es2019 - optional-catch', function (t) { var src = fs.readFileSync(__dirname + '/files/optional-catch.js'); t.doesNotThrow(detective.bind(detective, src), 'Files with omitted catch binding do not throw') t.end(); }); detective-5.2.0/test/es6-module.js000066400000000000000000000004351342354535700170040ustar00rootroot00000000000000var test = require('tap').test; var detective = require('../'); var fs = require('fs'); var src = fs.readFileSync(__dirname + '/files/es6-module.js'); test('es6-module', function (t) { t.plan(1); t.deepEqual(detective(src, {parse: {sourceType: 'module'}}), [ 'a', 'b' ]); }); detective-5.2.0/test/files/000077500000000000000000000000001342354535700155665ustar00rootroot00000000000000detective-5.2.0/test/files/both.js000066400000000000000000000001161342354535700170560ustar00rootroot00000000000000require('a'); require('b'); require('c' + x); var moo = require('d' + y).moo; detective-5.2.0/test/files/chained.js000066400000000000000000000001031342354535700175110ustar00rootroot00000000000000 require('c').hello().goodbye() require('b').hello() require('a') detective-5.2.0/test/files/es6-module.js000066400000000000000000000001201342354535700200750ustar00rootroot00000000000000var a = require('a'); export default function () { var b = require('b'); } detective-5.2.0/test/files/for-await.js000066400000000000000000000001531342354535700200140ustar00rootroot00000000000000async function main () { for await (const _ of (async function* () {})()) { require(_) } } detective-5.2.0/test/files/generators.js000066400000000000000000000001001342354535700202640ustar00rootroot00000000000000var a = require('a'); function *gen() { yield require('b'); }detective-5.2.0/test/files/isrequire.js000066400000000000000000000005031342354535700201320ustar00rootroot00000000000000var a = require.async('a'); var b = require.async('b'); var c = require.async('c'); var abc = a.b(c); var EventEmitter = require.async('events').EventEmitter; var x = require.async('doom')(5,6,7); x(8,9); c.load('notthis'); var y = require.async('y') * 100; var EventEmitter2 = require.async('events2').EventEmitter(); detective-5.2.0/test/files/nested.js000066400000000000000000000004451342354535700174110ustar00rootroot00000000000000 if (true) { (function () { require('a'); })(); } if (false) { (function () { var x = 10; switch (x) { case 1 : require('b'); break; default : break; } })() } function qqq () { require ( "c" ); } detective-5.2.0/test/files/optional-catch.js000066400000000000000000000000371342354535700210310ustar00rootroot00000000000000try { require; } catch { } detective-5.2.0/test/files/rest-spread.js000066400000000000000000000002351342354535700203550ustar00rootroot00000000000000var a = require('a'); var b = require('b'); var c = require('c'); var obj = { foo: 'bar', bee: 'bop' } var spread = { ...obj } var { foo, ...rest } = obj detective-5.2.0/test/files/set-in-object-pattern.js000066400000000000000000000002341342354535700222410ustar00rootroot00000000000000var a = load('a'); var b = load('b'); var c = load('c'); var abc = a.b(c); function load2({set = 'hello'}) { return load('tt'); } var loadUse = load2(); detective-5.2.0/test/files/shebang.js000066400000000000000000000001271342354535700175330ustar00rootroot00000000000000#!/usr/bin/env node var a = require('a'); var b = require('b'); var c = require('c'); detective-5.2.0/test/files/sparse-array.js000066400000000000000000000000411342354535700205300ustar00rootroot00000000000000var o = [,,,,] require('./foo') detective-5.2.0/test/files/strings.js000066400000000000000000000004321342354535700176140ustar00rootroot00000000000000var a = require('a'); var b = require('b'); var c = require('c'); var abc = a.b(c); var EventEmitter = require('events').EventEmitter; var x = require('doom')(5,6,7); x(8,9); c.require('notthis'); var y = require('y') * 100; var EventEmitter2 = require('events2').EventEmitter();detective-5.2.0/test/files/word.js000066400000000000000000000004031342354535700170740ustar00rootroot00000000000000var a = load('a'); var b = load('b'); var c = load('c'); var abc = a.b(c); var EventEmitter = load('events').EventEmitter; var x = load('doom')(5,6,7); x(8,9); c.load('notthis'); var y = load('y') * 100; var EventEmitter2 = load('events2').EventEmitter(); detective-5.2.0/test/files/yield.js000066400000000000000000000001241342354535700172270ustar00rootroot00000000000000(function * () { var a = require('a'); var b = yield require('c')(a); })(); detective-5.2.0/test/generators.js000066400000000000000000000003741342354535700171770ustar00rootroot00000000000000var test = require('tap').test; var detective = require('../'); var fs = require('fs'); var src = fs.readFileSync(__dirname + '/files/generators.js'); test('generators', function (t) { t.plan(1); t.deepEqual(detective(src), [ 'a', 'b' ]); }); detective-5.2.0/test/isrequire.js000066400000000000000000000012471342354535700170360ustar00rootroot00000000000000var test = require('tap').test; var detective = require('../'); var fs = require('fs'); var src = fs.readFileSync(__dirname + '/files/isrequire.js'); test('word', function (t) { t.deepEqual( detective(src, { isRequire: function(node) { return (node.type === 'CallExpression' && node.callee.type === 'MemberExpression' && node.callee.object.type == 'Identifier' && node.callee.object.name == 'require' && node.callee.property.type == 'Identifier' && node.callee.property.name == 'async') } }), [ 'a', 'b', 'c', 'events', 'doom', 'y', 'events2' ] ); t.end(); }); detective-5.2.0/test/nested.js000066400000000000000000000003671342354535700163120ustar00rootroot00000000000000var test = require('tap').test; var detective = require('../'); var fs = require('fs'); var src = fs.readFileSync(__dirname + '/files/nested.js'); test('nested', function (t) { t.deepEqual(detective(src), [ 'a', 'b', 'c' ]); t.end(); }); detective-5.2.0/test/noargs.js000066400000000000000000000015661342354535700163230ustar00rootroot00000000000000var test = require('tap').test; var detective = require('../'); var fs = require('fs'); // in order to use detective to find any function // it needs to properly handle functions called without args var src = [ 'fn();', 'otherfn();', 'fn();' ].join('\n') test('noargs', function (t) { t.plan(1); t.deepEqual(detective(src, { word: 'fn' }).length, 0, 'finds no arg id'); }); test('find noargs with nodes', function (t) { t.plan(4); var modules = detective.find(src, { word: 'fn', nodes: true }); t.equal(modules.strings.length, 0, 'finds no arg id'); t.equal(modules.expressions.length, 0, 'finds no expressions'); t.equal(modules.nodes.length, 2, 'finds a node for each matching function call'); t.equal( modules.nodes.filter(function (x) { return x.callee.name === 'fn' }).length, 2, 'all matches are correct' ); }); detective-5.2.0/test/parseopts.js000066400000000000000000000043361342354535700170500ustar00rootroot00000000000000var test = require('tap').test; var detective = require('../'); var fs = require('fs'); var src = fs.readFileSync(__dirname + '/files/both.js'); test('nodes specified in opts and parseopts { range: true }', function (t) { var modules = detective.find(src, { nodes: true, parse: { range: true } }); t.deepEqual(modules.strings, [ 'a', 'b' ]); t.deepEqual(modules.expressions, [ "'c' + x", "'d' + y" ]); t.deepEqual( modules.nodes.map(function (n) { var arg = n.arguments[0]; return arg.value || arg.left.value; }), [ 'a', 'b', 'c', 'd' ], 'has a node for each require'); var range = modules.nodes[0].range; t.equal(range[0], 0, 'includes range start'); t.equal(range[1], 12, 'includes range end'); t.end(); }); test('nodes specified in opts and parseopts { range: false }', function (t) { var modules = detective.find(src, { nodes: true, parse: { range: false } }); t.deepEqual(modules.strings, [ 'a', 'b' ]); t.deepEqual(modules.expressions, [ "'c' + x", "'d' + y" ]); t.deepEqual( modules.nodes.map(function (n) { var arg = n.arguments[0]; return arg.value || arg.left.value; }), [ 'a', 'b', 'c', 'd' ], 'has a node for each require'); t.notOk(modules.nodes[0].range, 'includes no ranges'); t.end(); }); test('nodes specified in opts and parseopts { range: true, loc: true }', function (t) { var modules = detective.find(src, { nodes: true, parse: { range: true, loc: true } }); t.deepEqual(modules.strings, [ 'a', 'b' ]); t.deepEqual(modules.expressions, [ "'c' + x", "'d' + y" ]); t.deepEqual( modules.nodes.map(function (n) { var arg = n.arguments[0]; return arg.value || arg.left.value; }), [ 'a', 'b', 'c', 'd' ], 'has a node for each require'); var range = modules.nodes[0].range; t.equal(range[0], 0, 'includes range start'); t.equal(range[1], 12, 'includes range end'); var loc = modules.nodes[0].loc; t.equal(loc.start.line, 1, 'includes start line'); t.equal(loc.start.column, 0, 'includes start column'); t.equal(loc.end.line, 1, 'includes end line'); t.equal(loc.end.column, 12, 'includes end column'); t.end(); }); detective-5.2.0/test/rest-spread.js000066400000000000000000000004521342354535700172540ustar00rootroot00000000000000var test = require('tap').test; var detective = require('../'); var fs = require('fs'); var src = fs.readFileSync(__dirname + '/files/rest-spread.js'); test('rest-spread', function (t) { t.doesNotThrow(detective.bind(detective, src), 'Files with rest or spread do not throw') t.end(); }); detective-5.2.0/test/return.js000066400000000000000000000003321342354535700163370ustar00rootroot00000000000000var test = require('tap').test; var detective = require('../'); var fs = require('fs'); var src = [ 'require("a")\nreturn' ]; test('return', function (t) { t.plan(1); t.deepEqual(detective(src), [ 'a' ]); }); detective-5.2.0/test/set-in-object-pattern.js000066400000000000000000000005031342354535700211360ustar00rootroot00000000000000var test = require('tap').test; var detective = require('../'); var fs = require('fs'); var src = fs.readFileSync(__dirname + '/files/set-in-object-pattern.js'); test('set in object pattern', function (t) { t.deepEqual( detective(src, { word : 'load' }), [ 'a', 'b', 'c', 'tt' ] ); t.end(); });detective-5.2.0/test/shebang.js000066400000000000000000000003731342354535700164340ustar00rootroot00000000000000var test = require('tap').test; var detective = require('../'); var fs = require('fs'); var src = fs.readFileSync(__dirname + '/files/shebang.js'); test('shebang', function (t) { t.plan(1); t.deepEqual(detective(src), [ 'a', 'b', 'c' ]); }); detective-5.2.0/test/sparse-array.js000066400000000000000000000004711342354535700174350ustar00rootroot00000000000000var test = require('tap').test; var detective = require('../'); var fs = require('fs'); var src = fs.readFileSync(__dirname + '/files/sparse-array.js'); test('sparse-array', function (t) { //just check that this does not crash. t.doesNotThrow(function () { detective(src) }) t.end(); }); detective-5.2.0/test/strings.js000066400000000000000000000004321342354535700165120ustar00rootroot00000000000000var test = require('tap').test; var detective = require('../'); var fs = require('fs'); var src = fs.readFileSync(__dirname + '/files/strings.js'); test('single', function (t) { t.deepEqual(detective(src), [ 'a', 'b', 'c', 'events', 'doom', 'y', 'events2' ]); t.end(); }); detective-5.2.0/test/word.js000066400000000000000000000004761342354535700160040ustar00rootroot00000000000000var test = require('tap').test; var detective = require('../'); var fs = require('fs'); var src = fs.readFileSync(__dirname + '/files/word.js'); test('word', function (t) { t.deepEqual( detective(src, { word : 'load' }), [ 'a', 'b', 'c', 'events', 'doom', 'y', 'events2' ] ); t.end(); }); detective-5.2.0/test/yield.js000066400000000000000000000003621342354535700161310ustar00rootroot00000000000000var test = require('tap').test; var detective = require('../'); var fs = require('fs'); var src = fs.readFileSync(__dirname + '/files/yield.js'); test('yield', function (t) { t.plan(1); t.deepEqual(detective(src), [ 'a', 'c' ]); });