js-restructure
Advanced tools
Comparing version
21
index.js
module.exports = function matcher(obj) { | ||
"use strict"; | ||
var props = Object.getOwnPropertyNames(obj); | ||
var re = new RegExp(props.reduce(function(p, c) { | ||
return p + (c.startsWith("_") ? obj[c] : ("("+obj[c] + ")"); | ||
})); | ||
props = props.filter(function(x) { return !x.startsWith("_"); }); | ||
return function(pattern) { | ||
"use strict"; | ||
var props = Object.getOwnPropertyNames(obj); | ||
var re = new RegExp(props.reduce(function(p, c) { | ||
if(c.indexOf("_") === 0) return p + obj[c]; | ||
else return p + "(" + obj[c] + ")"; | ||
}, "")); | ||
props = props.filter(function(x) { return !x.startsWith("_"); }); | ||
return function(pattern) { | ||
var o = {}; | ||
var res = re.exec(pattern); | ||
if(res === null) return null; | ||
for(var i = 0; i < res.length; i++) { | ||
@@ -16,3 +17,3 @@ o[props[i]] = res[i + 1]; | ||
return o; | ||
}; | ||
} | ||
}; | ||
}; |
{ | ||
"name": "js-restructure", | ||
"version": "1.0.1", | ||
"version": "1.0.2", | ||
"description": "This package provides a nifty way to match against regular expressions\u001b[D\u001b[D\u001b[D\u001b[D\u001b[D\u001b[D\u001b[D\u001b[D\u001b[D\u001b[D\u001b[D\u001b[D\u001b[D\u001b[D\u001b[D\u001b[D\u001b[D\u001b[D\u001b[D\u001b[D\u001b[D\u001b[D\u001b[D\u001b[D\u001b[D\u001b[D\u001b[D\u001b[D\u001b[D\u001b[D\u001b[D\u001bconstruct and match against regular expressions.", | ||
"main": "index.js", | ||
"scripts": { | ||
"test": "mocha" | ||
"test": "mocha tests" | ||
}, | ||
@@ -19,3 +19,6 @@ "repository": { | ||
"author": "Benjamin Gruenbaum", | ||
"license": "MIT" | ||
"license": "MIT", | ||
"devDependencies": { | ||
"mocha": "^2.3.4" | ||
} | ||
} |
URL strings
Supply chain riskPackage contains fragments of external URLs or IP addresses, which the package may be accessing at runtime.
Found 1 instance in 1 package
3367
51.19%53
231.25%1
Infinity%1
Infinity%