Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

object-scan

Package Overview
Dependencies
Maintainers
1
Versions
200
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

object-scan - npm Package Compare versions

Comparing version 1.1.5 to 1.1.6

15

lib/index.js
const parser = require("./util/parser");
module.exports = (needles, valueFn = undefined) => {
module.exports = (needles, valueFn = undefined, joined = true) => {
const search = needles.map(parser);
const find = (haystack, checks, pathIn = undefined) => {
const find = (haystack, checks, pathIn = []) => {
const result = [];

@@ -11,3 +11,6 @@

if (valueFn === undefined || valueFn(haystack)) {
result.push(pathIn);
result.push(joined ? pathIn.reduce((p, c) => {
const isNumber = typeof c === "number";
return `${p}${p === "" || isNumber ? "" : "."}${isNumber ? `[${c}]` : c}`;
}, "") : pathIn);
}

@@ -20,3 +23,3 @@ }

checks.filter(check => check.length !== 0).forEach(check => {
const pathOut = `${pathIn === undefined ? "" : pathIn}[${i}]`;
const pathOut = [].concat(...pathIn).concat(i);

@@ -34,3 +37,3 @@ if (check[0] === "**") {

const escapedKey = key.replace(/[,.*[\]{}]/g, "\\$&");
const pathOut = pathIn === undefined ? escapedKey : `${pathIn}.${escapedKey}`;
const pathOut = [].concat(...pathIn).concat(key);

@@ -52,2 +55,2 @@ if (check[0] === "**") {

};
//# sourceMappingURL=data:application/json;charset=utf-8;base64,eyJ2ZXJzaW9uIjozLCJzb3VyY2VzIjpbIi4uL3NyYy9pbmRleC5qcyJdLCJuYW1lcyI6WyJwYXJzZXIiLCJyZXF1aXJlIiwibW9kdWxlIiwiZXhwb3J0cyIsIm5lZWRsZXMiLCJ2YWx1ZUZuIiwidW5kZWZpbmVkIiwic2VhcmNoIiwibWFwIiwiZmluZCIsImhheXN0YWNrIiwiY2hlY2tzIiwicGF0aEluIiwicmVzdWx0Iiwic29tZSIsImNoZWNrIiwibGVuZ3RoIiwicHVzaCIsIk9iamVjdCIsIkFycmF5IiwiaXNBc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IFtdO1xuICAgIGlmIChjaGVja3Muc29tZShjaGVjayA9PiBjaGVjay5sZW5ndGggPT09IDApKSB7XG4gICAgICBpZiAodmFsdWVGbiA9PT0gdW5kZWZpbmVkIHx8IHZhbHVlRm4oaGF5c3RhY2spKSB7XG4gICAgICAgIHJlc3VsdC5wdXNoKHBhdGhJbik7XG4gICAgICB9XG4gICAgfVxuICAgIGlmIChoYXlzdGFjayBpbnN0YW5jZW9mIE9iamVjdCkge1xuICAgICAgaWYgKEFycmF5LmlzQXJyYXkoaGF5c3RhY2spKSB7XG4gICAgICAgIGZvciAobGV0IGkgPSAwOyBpIDwgaGF5c3RhY2subGVuZ3RoOyBpICs9IDEpIHtcbiAgICAgICAgICBjaGVja3NcbiAgICAgICAgICAgIC5maWx0ZXIoY2hlY2sgPT4gY2hlY2subGVuZ3RoICE9PSAwKVxuICAgICAgICAgICAgLmZvckVhY2goKGNoZWNrKSA9PiB7XG4gICAgICAgICAgICAgIGNvbnN0IHBhdGhPdXQgPSBgJHtwYXRoSW4gPT09IHVuZGVmaW5lZCA/IFwiXCIgOiBwYXRoSW59WyR7aX1dYDtcbiAgICAgICAgICAgICAgaWYgKGNoZWNrWzBdID09PSBcIioqXCIpIHtcbiAgICAgICAgICAgICAgICByZXN1bHQucHVzaCguLi5maW5kKGhheXN0YWNrW2ldLCBbY2hlY2ssIGNoZWNrLnNsaWNlKDEpXSwgcGF0aE91dCkpO1xuICAgICAgICAgICAgICB9IGVsc2UgaWYgKFxuICAgICAgICAgICAgICAgIGNoZWNrWzBdID09PSBcIlsqXVwiIHx8XG4gICAgICAgICAgICAgICAgY2hlY2tbMF0gPT09IGBbJHtpfV1gIHx8XG4gICAgICAgICAgICAgICAgKGNoZWNrWzBdIGluc3RhbmNlb2YgQXJyYXkgJiYgY2hlY2tbMF0uaW5kZXhPZihgWyR7aX1dYCkgIT09IC0xKVxuICAgICAgICAgICAgICApIHtcbiAgICAgICAgICAgICAgICByZXN1bHQucHVzaCguLi5maW5kKGhheXN0YWNrW2ldLCBbY2hlY2suc2xpY2UoMSldLCBwYXRoT3V0KSk7XG4gICAgICAgICAgICAgIH1cbiAgICAgICAgICAgIH0pO1xuICAgICAgICB9XG4gICAgICB9IGVsc2Uge1xuICAgICAgICBPYmplY3Qua2V5cyhoYXlzdGFjaykuZm9yRWFjaCgoa2V5KSA9PiB7XG4gICAgICAgICAgY2hlY2tzXG4gICAgICAgICAgICAuZmlsdGVyKGNoZWNrID0+IGNoZWNrLmxlbmd0aCAhPT0gMClcbiAgICAgICAgICAgIC5mb3JFYWNoKChjaGVjaykgPT4ge1xuICAgICAgICAgICAgICBjb25zdCBlc2NhcGVkS2V5ID0ga2V5LnJlcGxhY2UoL1ssLipbXFxde31dL2csIFwiXFxcXCQmXCIpO1xuICAgICAgICAgICAgICBjb25zdCBwYXRoT3V0ID0gcGF0aEluID09PSB1bmRlZmluZWQgPyBlc2NhcGVkS2V5IDogYCR7cGF0aElufS4ke2VzY2FwZWRLZXl9YDtcbiAgICAgICAgICAgICAgaWYgKGNoZWNrWzBdID09PSBcIioqXCIpIHtcbiAgICAgICAgICAgICAgICByZXN1bHQucHVzaCguLi5maW5kKGhheXN0YWNrW2tleV0sIFtjaGVjaywgY2hlY2suc2xpY2UoMSldLCBwYXRoT3V0KSk7XG4gICAgICAgICAgICAgIH0gZWxzZSBpZiAoXG4gICAgICAgICAgICAgICAgY2hlY2tbMF0gPT09IFwiKlwiIHx8XG4gICAgICAgICAgICAgICAgY2hlY2tbMF0gPT09IGVzY2FwZWRLZXkgfHxcbiAgICAgICAgICAgICAgICAoY2hlY2tbMF0gaW5zdGFuY2VvZiBBcnJheSAmJiBjaGVja1swXS5pbmRleE9mKGVzY2FwZWRLZXkpICE9PSAtMSlcbiAgICAgICAgICAgICAgKSB7XG4gICAgICAgICAgICAgICAgcmVzdWx0LnB1c2goLi4uZmluZChoYXlzdGFja1trZXldLCBbY2hlY2suc2xpY2UoMSldLCBwYXRoT3V0KSk7XG4gICAgICAgICAgICAg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FsdWVGbihoYXlzdGFjaykpIHtcbiAgICAgICAgcmVzdWx0LnB1c2goam9pbmVkID8gcGF0aEluLnJlZHVjZSgocCwgYykgPT4ge1xuICAgICAgICAgIGNvbnN0IGlzTnVtYmVyID0gdHlwZW9mIGMgPT09IFwibnVtYmVyXCI7XG4gICAgICAgICAgcmV0dXJuIGAke3B9JHtwID09PSBcIlwiIHx8IGlzTnVtYmVyID8gXCJcIiA6IFwiLlwifSR7aXNOdW1iZXIgPyBgWyR7Y31dYCA6IGN9YDtcbiAgICAgICAgfSwgXCJcIikgOiBwYXRoSW4pO1xuICAgICAgfVxuICAgIH1cbiAgICBpZiAoaGF5c3RhY2sgaW5zdGFuY2VvZiBPYmplY3QpIHtcbiAgICAgIGlmIChBcnJheS5pc0FycmF5KGhheXN0YWNrKSkge1xuICAgICAgICBmb3IgKGxldCBpID0gMDsgaSA8IGhheXN0YWNrLmxlbmd0aDsgaSArPSAxKSB7XG4gICAgICAgICAgY2hlY2tzXG4gICAgICAgICAgICAuZmlsdGVyKGNoZWNrID0+IGNoZWNrLmxlbmd0aCAhPT0gMClcbiAgICAgICAgICAgIC5mb3JFYWNoKChjaGVjaykgPT4ge1xuICAgICAgICAgICAgICBjb25zdCBwYXRoT3V0ID0gW10uY29uY2F0KC4uLnBhdGhJbikuY29uY2F0KGkpO1xuICAgICAgICAgICAgICBpZiAoY2hlY2tbMF0gPT09IFwiKipcIikge1xuICAgICAgICAgICAgICAgIHJlc3VsdC5wdXNoKC4uLmZpbmQoaGF5c3RhY2tbaV0sIFtjaGVjaywgY2hlY2suc2xpY2UoMSldLCBwYXRoT3V0KSk7XG4gICAgICAgICAgICAgIH0gZWxzZSBpZiAoXG4gICAgICAgICAgICAgICAgY2hlY2tbMF0gPT09IFwiWypdXCIgfHxcbiAgICAgICAgICAgICAgICBjaGVja1swXSA9PT0gYFske2l9XWAgfHxcbiAgICAgICAgICAgICAgICAoY2hlY2tbMF0gaW5zdGFuY2VvZiBBcnJheSAmJiBjaGVja1swXS5pbmRleE9mKGBbJHtpfV1gKSAhPT0gLTEpXG4gICAgICAgICAgICAgICkge1xuICAgICAgICAgICAgICAgIHJlc3VsdC5wdXNoKC4uLmZpbmQoaGF5c3RhY2tbaV0sIFtjaGVjay5zbGljZSgxKV0sIHBhdGhPdXQpKTtcbiAgICAgICAgICAgICAgfVxuICAgICAgICAgICAgfSk7XG4gICAgICAgIH1cbiAgICAgIH0gZWxzZSB7XG4gICAgICAgIE9iamVjdC5rZXlzKGhheXN0YWNrKS5mb3JFYWNoKChrZXkpID0+IHtcbiAgICAgICAgICBjaGVja3NcbiAgICAgICAgICAgIC5maWx0ZXIoY2hlY2sgPT4gY2hlY2subGVuZ3RoICE9PSAwKVxuICAgICAgICAgICAgLmZvckVhY2goKGNoZWNrKSA9PiB7XG4gICAgICAgICAgICAgIGNvbnN0IGVzY2FwZWRLZXkgPSBrZXkucmVwbGFjZSgvWywuKltcXF17fV0vZywgXCJcXFxcJCZcIik7XG4gICAgICAgICAgICAgIGNvbnN0IHBhdGhPdXQgPSBbXS5jb25jYXQoLi4ucGF0aEluKS5jb25jYXQoa2V5KTtcbiAgICAgICAgICAgICAgaWYgKGNoZWNrWzBdID09PSBcIioqXCIpIHtcbiAgICAgICAgICAgICAgICByZXN1bHQucHVzaCguLi5maW5kKGhheXN0YWNrW2tleV0sIFtjaGVjaywgY2hlY2suc2xpY2UoMSldLCBwYXRoT3V0KSk7XG4gICAgICAgICAgICAgIH0gZWxzZSBpZiAoXG4gICAgICAgICAgICAgICAgY2hlY2tbMF0gPT09IFwiKlwiIHx8XG4gICAgICAgICAgICAgICAgY2hlY2tbMF0gPT09IGVzY2FwZWRLZXkgfHxcbiAgICAgICAgICAgICAgICAoY2hlY2tbMF0gaW5zdGFuY2VvZiBBcnJheSAmJiBjaGVja1swXS5pbmRleE9mKGVzY2FwZWRLZXkpICE9PSAtMSlcbiAgICAgICAgICAgICAgKSB7XG4gICAgICAgICAgICAgICAgcmVzdWx0LnB1c2goLi4uZmluZChoYXlzdGFja1trZXldLCBbY2hlY2suc2xpY2UoMSldLCBwYXRoT3V0KSk7XG4gICAgICAgICAgICAgIH1cbiAgICAgICAgICAgIH0pO1xuICAgICAgICB9KTtcbiAgICAgIH1cbiAgICB9XG4gICAgcmV0dXJuIHJlc3VsdDtcbiAgfTtcblxuICByZXR1cm4gaGF5c3RhY2sgPT4gZmluZChoYXlzdGFjaywgc2VhcmNoKTtcbn07XG4iXX0=

2

package.json
{
"name": "object-scan",
"version": "1.1.5",
"version": "1.1.6",
"description": "Find Keys using Wildcard matching and optional value function.",

@@ -5,0 +5,0 @@ "main": "lib/index.js",

@@ -31,2 +31,12 @@ # Object-Scan

### Value Function
Constructor takes second value function parameter which gets passed in the value of the key and is expected to return true or false.
Only results where the value function returns true are returned.
### Joined
When dealing with special characters it might be desired to not have the output merged. In this case
the constructor takes a third option which can be set to false to return each key as a list.
## Examples

@@ -66,2 +76,4 @@

// => ["a.b.c", "a.e.f"]
objectScan(["a.*.{c,f}"], () => true, false)(obj);
// => [["a", "b", "c"], ["a", "e", "f"]]

@@ -91,1 +103,3 @@ // list filter

be escaped if they should be matched in a key: `[`, `]`, `{`, `}`, `,`, `.` and `*`.
When dealing with special characters the `joined` option might be desirable to set to `false`.
SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc