Package Exports
- match-requires
This package does not declare an exports field, so the exports above have been automatically detected and optimized by JSPM instead. If any package subpath is missing, it is recommended to post an issue to the original package (match-requires) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.
Readme
match-requires 
Match require statements in a string. Returns an array of matching require statements. Each match is an object with line number, variable name, and module name. Statements in code comments are ignored.
Install
Install with npm:
npm i match-requires --save-dev
Run tests
npm test
Usage
var re = require('match-requires');
console.log(re('require(\'a-b-c\');\nvar fooBar = require(\'foo-bar\');'))
Returns:
[ { line: 1,
variable: '',
module: 'a-b-c',
original: 'require(\'a-b-c\');' },
{ line: 2,
variable: 'fooBar',
module: 'foo-bar',
original: 'var fooBar = require(\'foo-bar\');' } ]
Code comments
To ignore require statements found in code comments, pass true
as the second arg:
re('/* require(\'a-b-c\');*/\nvar fooBar = require(\'foo-bar\');');
Returns:
[ { line: 2,
variable: 'fooBar',
module: 'foo-bar',
original: 'var fooBar = require(\'foo-bar\');' } ]
You may also pass a custom function for stripping code comments.
var str = '/* require(\'a-b-c\');*/\nvar fooBar = require(\'foo-bar\');';
re(str, function(content) {
return content.replace(/foo/, '');
});
Author
Jon Schlinkert
License
Copyright (c) 2014 Jon Schlinkert
Released under the MIT license
This file was generated by verb on November 23, 2014.