js-restructure
Advanced tools
Comparing version 1.0.1 to 1.0.2
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" | ||
} | ||
} |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
3367
53
1