match-requires
Advanced tools
+42
| # {%= name %} {%= badge("fury") %} | ||
| > {%= description %} | ||
| ## Install | ||
| {%= include("install") %} | ||
| ## Run tests | ||
| ```bash | ||
| npm test | ||
| ``` | ||
| ## Usage | ||
| ```js | ||
| var re = require('{%= name %}'); | ||
| console.log(re('require(\'a-b-c\');\nvar fooBar = require(\'foo-bar\');')) | ||
| ``` | ||
| Returns: | ||
| ```js | ||
| [ { 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\');' } ] | ||
| ``` | ||
| ## Author | ||
| {%= include("author") %} | ||
| ## License | ||
| {%= copyright() %} | ||
| {%= license() %} | ||
| *** | ||
| {%= include("footer") %} |
+16
-9
@@ -15,15 +15,22 @@ /*! | ||
| str = str.replace(/\r/g, ''); | ||
| str = stripComments(str).split(/\n/g); | ||
| return str.reduce(function (acc, line, i) { | ||
| if (regex().exec(line)) { | ||
| acc.push({ | ||
| line: i + 1, | ||
| variable: RegExp.$2, | ||
| module: RegExp.$3, | ||
| var lines = stripComments(str).split(/\n/g); | ||
| var len = lines.length; | ||
| var i = 0; | ||
| var arr = []; | ||
| var match; | ||
| while (len--) { | ||
| var line = lines[i++]; | ||
| if (match = regex().exec(line)) { | ||
| arr = arr.concat({ | ||
| line: i, | ||
| variable: match[2] || '', | ||
| module: match[3], | ||
| original: line | ||
| }); | ||
| } | ||
| return acc; | ||
| }, []); | ||
| } | ||
| return arr; | ||
| }; |
+1
-1
| { | ||
| "name": "match-requires", | ||
| "description": "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.", | ||
| "version": "0.1.1", | ||
| "version": "0.1.2", | ||
| "homepage": "https://github.com/jonschlinkert/match-requires", | ||
@@ -6,0 +6,0 @@ "author": { |
+3
-4
| # match-requires [](http://badge.fury.io/js/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](npmjs.org): | ||
| ### Install with [npm](npmjs.org): | ||
@@ -46,3 +45,3 @@ ```bash | ||
| ## License | ||
| Copyright (c) 2014 Jon Schlinkert, contributors. | ||
| Copyright (c) 2014 Jon Schlinkert | ||
| Released under the MIT license | ||
@@ -52,2 +51,2 @@ | ||
| _This file was generated by [verb-cli](https://github.com/assemble/verb-cli) on September 20, 2014._ | ||
| _This file was generated by [verb](https://github.com/assemble/verb) on November 17, 2014._ |
-42
| # {%= name %} {%= badge("fury") %} | ||
| > {%= description %} | ||
| ## Install | ||
| {%= include("install") %} | ||
| ## Run tests | ||
| ```bash | ||
| npm test | ||
| ``` | ||
| ## Usage | ||
| ```js | ||
| var re = require('{%= name %}'); | ||
| console.log(re('require(\'a-b-c\');\nvar fooBar = require(\'foo-bar\');')) | ||
| ``` | ||
| Returns: | ||
| ```js | ||
| [ { 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\');' } ] | ||
| ``` | ||
| ## Author | ||
| {%= include("author") %} | ||
| ## License | ||
| {%= copyright() %} | ||
| {%= license() %} | ||
| *** | ||
| {%= include("footer") %} |
Dynamic require
Supply chain riskDynamic require can indicate the package is performing dangerous or unsafe dynamic code execution.
Found 1 instance in 1 package
Dynamic require
Supply chain riskDynamic require can indicate the package is performing dangerous or unsafe dynamic code execution.
Found 1 instance in 1 package
7072
0.81%63
8.62%50
-1.96%