require-call
A more simple way to find all require() calls.
Installation
npm install require-call
Usage
API
parseDependencies(code: String, replace: Function = null)
Example
Source code:
// require('bar')
const fs = const resolve = fs
Output:
code: 'require(\'foo\')\n// require(\'bar\')\n' resource: string: 'require(\'foo\')' path: 'foo' start: 0 end: 14
Benchmark
require-call: deps x 170,457 ops/sec ±1.10% crequire: deps x 30,942 ops/sec ±1.05% detective: deps x 25,083 ops/sec ±4.37% [ 'require-call: deps' ]require-call: async x 339,991 ops/sec ±1.85% crequire: async x 51,265 ops/sec ±3.44% detective: async x 33,586 ops/sec ±1.37% [ 'require-call: async' ]require-call: generators x 220,163 ops/sec ±1.27% crequire: generators x 41,673 ops/sec ±1.22% detective: generators x 30,486 ops/sec ±4.88% [ 'require-call: generators' ]require-call: ignore x 77,263 ops/sec ±1.11% crequire: ignore x 28,153 ops/sec ±1.08% detective: ignore x 19,288 ops/sec ±1.35% [ 'require-call: ignore' ]require-call: nested x 73,550 ops/sec ±3.86% crequire: nested x 20,056 ops/sec ±1.70% detective: nested x 18,324 ops/sec ±3.06% [ 'require-call: nested' ]
Development
npm run testnpm run benchmark
Thanks
License
MIT