pax_global_header00006660000000000000000000000064142441727310014517gustar00rootroot0000000000000052 comment=ee46789f97b5625040e72d1e49b4a1bf47fe9362 detective-5.2.1/000077500000000000000000000000001424417273100135005ustar00rootroot00000000000000detective-5.2.1/.gitignore000066400000000000000000000000411424417273100154630ustar00rootroot00000000000000node_modules bench/src/jquery.js detective-5.2.1/.npmignore000066400000000000000000000000241424417273100154730ustar00rootroot00000000000000bench/src/jquery.js detective-5.2.1/.npmrc000066400000000000000000000000231424417273100146130ustar00rootroot00000000000000package-lock=false detective-5.2.1/.travis.yml000066400000000000000000000003151424417273100156100ustar00rootroot00000000000000language: 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.1/CHANGELOG.md000066400000000000000000000021211424417273100153050ustar00rootroot00000000000000# detective Change Log All notable changes to this project will be documented in this file. This project adheres to [Semantic Versioning](http://semver.org/). ## x.y.z - unreleased * update acorn-node to 1.8.2 (make use of acorn 7.x) ## 5.2.1 - 2022-05-27 * Update to "minimist": "^1.2.6" from "^1.1.1" to quiet down dependabot security theater. ## 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.1/LICENSE000066400000000000000000000020611424417273100145040ustar00rootroot00000000000000This 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.1/bench/000077500000000000000000000000001424417273100145575ustar00rootroot00000000000000detective-5.2.1/bench/detect.js000066400000000000000000000003141424417273100163630ustar00rootroot00000000000000var 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.1/bench/esprima_v_acorn.txt000066400000000000000000000002521424417273100204660ustar00rootroot00000000000000esprima: $ 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.1/bin/000077500000000000000000000000001424417273100142505ustar00rootroot00000000000000detective-5.2.1/bin/detective.js000077500000000000000000000004451424417273100165700ustar00rootroot00000000000000#!/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.1/example/000077500000000000000000000000001424417273100151335ustar00rootroot00000000000000detective-5.2.1/example/strings.js000066400000000000000000000002511424417273100171600ustar00rootroot00000000000000var detective = require('../'); var fs = require('fs'); var src = fs.readFileSync(__dirname + '/strings_src.js'); var requires = detective(src); console.dir(requires); detective-5.2.1/example/strings_src.js000066400000000000000000000001021424417273100200220ustar00rootroot00000000000000var a = require('a'); var b = require('b'); var c = require('c'); detective-5.2.1/index.js000066400000000000000000000052051424417273100151470ustar00rootroot00000000000000var 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.1/package.json000066400000000000000000000013111424417273100157620ustar00rootroot00000000000000{ "name": "detective", "description": "find all require() calls by walking the AST", "version": "5.2.1", "author": { "name": "James Halliday", "email": "mail@substack.net", "url": "http://substack.net" }, "bin": "bin/detective.js", "dependencies": { "acorn-node": "^1.8.2", "defined": "^1.0.0", "minimist": "^1.2.6" }, "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.1/readme.markdown000066400000000000000000000032421424417273100165020ustar00rootroot00000000000000# 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.1/test/000077500000000000000000000000001424417273100144575ustar00rootroot00000000000000detective-5.2.1/test/both.js000066400000000000000000000015131424417273100157510ustar00rootroot00000000000000var 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.1/test/chained.js000066400000000000000000000003711424417273100164110ustar00rootroot00000000000000var 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.1/test/complicated.js000066400000000000000000000033541424417273100173060ustar00rootroot00000000000000var 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.1/test/es2019.js000066400000000000000000000010361424417273100157400ustar00rootroot00000000000000var 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.1/test/es6-module.js000066400000000000000000000004351424417273100167770ustar00rootroot00000000000000var 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.1/test/files/000077500000000000000000000000001424417273100155615ustar00rootroot00000000000000detective-5.2.1/test/files/both.js000066400000000000000000000001161424417273100170510ustar00rootroot00000000000000require('a'); require('b'); require('c' + x); var moo = require('d' + y).moo; detective-5.2.1/test/files/chained.js000066400000000000000000000001031424417273100175040ustar00rootroot00000000000000 require('c').hello().goodbye() require('b').hello() require('a') detective-5.2.1/test/files/es6-module.js000066400000000000000000000001201424417273100200700ustar00rootroot00000000000000var a = require('a'); export default function () { var b = require('b'); } detective-5.2.1/test/files/for-await.js000066400000000000000000000001531424417273100200070ustar00rootroot00000000000000async function main () { for await (const _ of (async function* () {})()) { require(_) } } detective-5.2.1/test/files/generators.js000066400000000000000000000001001424417273100202570ustar00rootroot00000000000000var a = require('a'); function *gen() { yield require('b'); }detective-5.2.1/test/files/isrequire.js000066400000000000000000000005031424417273100201250ustar00rootroot00000000000000var 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.1/test/files/nested.js000066400000000000000000000004451424417273100174040ustar00rootroot00000000000000 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.1/test/files/optional-catch.js000066400000000000000000000000371424417273100210240ustar00rootroot00000000000000try { require; } catch { } detective-5.2.1/test/files/rest-spread.js000066400000000000000000000002351424417273100203500ustar00rootroot00000000000000var 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.1/test/files/set-in-object-pattern.js000066400000000000000000000002341424417273100222340ustar00rootroot00000000000000var 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.1/test/files/shebang.js000066400000000000000000000001271424417273100175260ustar00rootroot00000000000000#!/usr/bin/env node var a = require('a'); var b = require('b'); var c = require('c'); detective-5.2.1/test/files/sparse-array.js000066400000000000000000000000411424417273100205230ustar00rootroot00000000000000var o = [,,,,] require('./foo') detective-5.2.1/test/files/strings.js000066400000000000000000000004321424417273100176070ustar00rootroot00000000000000var 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.1/test/files/word.js000066400000000000000000000004031424417273100170670ustar00rootroot00000000000000var 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.1/test/files/yield.js000066400000000000000000000001241424417273100172220ustar00rootroot00000000000000(function * () { var a = require('a'); var b = yield require('c')(a); })(); detective-5.2.1/test/generators.js000066400000000000000000000003741424417273100171720ustar00rootroot00000000000000var 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.1/test/isrequire.js000066400000000000000000000012471424417273100170310ustar00rootroot00000000000000var 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.1/test/nested.js000066400000000000000000000003671424417273100163050ustar00rootroot00000000000000var 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.1/test/noargs.js000066400000000000000000000015661424417273100163160ustar00rootroot00000000000000var 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.1/test/parseopts.js000066400000000000000000000043361424417273100170430ustar00rootroot00000000000000var 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.1/test/rest-spread.js000066400000000000000000000004521424417273100172470ustar00rootroot00000000000000var 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.1/test/return.js000066400000000000000000000003321424417273100163320ustar00rootroot00000000000000var 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.1/test/set-in-object-pattern.js000066400000000000000000000005031424417273100211310ustar00rootroot00000000000000var 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.1/test/shebang.js000066400000000000000000000003731424417273100164270ustar00rootroot00000000000000var 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.1/test/sparse-array.js000066400000000000000000000004711424417273100174300ustar00rootroot00000000000000var 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.1/test/strings.js000066400000000000000000000004321424417273100165050ustar00rootroot00000000000000var 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.1/test/word.js000066400000000000000000000004761424417273100157770ustar00rootroot00000000000000var 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.1/test/yield.js000066400000000000000000000003621424417273100161240ustar00rootroot00000000000000var 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' ]); });