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.2.2 to 1.3.0

107

lib/index.js

@@ -0,1 +1,3 @@

const uniq = require("lodash.uniq");
const parser = require("./util/parser");

@@ -5,57 +7,74 @@

module.exports = (needles, {
filterFn = undefined,
breakFn = undefined,
joined = true
} = {}) => {
const search = needles.map(parser);
const compare = (wildcard, input, arr, ctx) => {
if (arr && !wildcard.match(/^\[.*]$/)) {
return false;
}
const find = (haystack, checks, pathIn = []) => {
const result = [];
if (ctx.regexCache[wildcard] === undefined) {
ctx.regexCache[wildcard] = new RegExp(`^${wildcard.split(/(?<!\\)(?:\\\\)*\*/).map(p => p.replace(/[|\\{}()[\]^$+*?.]/g, '\\$&')).join(".*")}$`);
}
if (checks.some(check => check.length === 0)) {
if (filterFn === undefined || filterFn(pathIn.map(escape).join("."), haystack)) {
result.push(joined ? pathIn.reduce((p, c) => {
const isNumber = typeof c === "number";
return `${p}${p === "" || isNumber ? "" : "."}${isNumber ? `[${c}]` : c}`;
}, "") : pathIn);
}
}
return input.match(ctx.regexCache[wildcard]);
};
if (breakFn === undefined || !breakFn(pathIn.map(escape).join("."), haystack)) {
if (haystack instanceof Object) {
if (Array.isArray(haystack)) {
for (let i = 0; i < haystack.length; i += 1) {
checks.filter(check => check.length !== 0).forEach(check => {
const pathOut = [].concat(...pathIn).concat(i);
const matches = (wildcard, input, arr, ctx) => Array.isArray(wildcard) ? wildcard.some(wc => matches(wc, input, arr, ctx)) : wildcard === (arr ? "[*]" : "*") || compare(wildcard, input, arr, ctx);
if (check[0] === "**") {
result.push(...find(haystack[i], [check, check.slice(1)], pathOut));
} else if (check[0] === "[*]" || check[0] === `[${i}]` || check[0] instanceof Array && check[0].indexOf(`[${i}]`) !== -1) {
result.push(...find(haystack[i], [check.slice(1)], pathOut));
}
});
}
} else {
Object.keys(haystack).forEach(key => {
checks.filter(check => check.length !== 0).forEach(check => {
const escapedKey = escape(key);
const pathOut = [].concat(...pathIn).concat(key);
const find = (haystack, checks, pathIn, ctx) => {
const result = [];
if (check[0] === "**") {
result.push(...find(haystack[key], [check, check.slice(1)], pathOut));
} else if (check[0] === "*" || check[0] === escapedKey || check[0] instanceof Array && check[0].indexOf(escapedKey) !== -1) {
result.push(...find(haystack[key], [check.slice(1)], pathOut));
}
});
if (checks.some(check => check.length === 0)) {
if (ctx.filterFn === undefined || ctx.filterFn(pathIn.map(escape).join("."), haystack)) {
result.push(ctx.joined ? pathIn.reduce((p, c) => {
const isNumber = typeof c === "number";
return `${p}${p === "" || isNumber ? "" : "."}${isNumber ? `[${c}]` : c}`;
}, "") : pathIn);
}
}
if (ctx.breakFn === undefined || !ctx.breakFn(pathIn.map(escape).join("."), haystack)) {
if (typeof haystack === "object") {
if (Array.isArray(haystack)) {
for (let i = 0; i < haystack.length; i += 1) {
const pathOut = pathIn.concat(i);
checks.filter(check => check.length !== 0).forEach(check => {
if (check[0] === "**") {
result.push(...find(haystack[i], [check, check.slice(1)], pathOut, ctx));
} else if (matches(check[0], `[${i}]`, true, ctx)) {
result.push(...find(haystack[i], [check.slice(1)], pathOut, ctx));
}
});
}
} else {
Object.entries(haystack).forEach(([key, value]) => {
const escapedKey = escape(key);
const pathOut = pathIn.concat(key);
checks.filter(check => check.length !== 0).forEach(check => {
if (check[0] === "**") {
result.push(...find(value, [check, check.slice(1)], pathOut, ctx));
} else if (matches(check[0], escapedKey, false, ctx)) {
result.push(...find(value, [check.slice(1)], pathOut, ctx));
}
});
});
}
}
}
return result;
};
return result;
};
return haystack => find(haystack, search);
module.exports = (needles, {
filterFn = undefined,
breakFn = undefined,
joined = true
} = {}) => {
const search = uniq(needles).map(parser);
const regexCache = {};
return haystack => uniq(find(haystack, search, [], {
filterFn,
breakFn,
joined,
regexCache
}));
};
//# sourceMapp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9yIChsZXQgaSA9IDA7IGkgPCBoYXlzdGFjay5sZW5ndGg7IGkgKz0gMSkge1xuICAgICAgICAgICAgY2hlY2tzXG4gICAgICAgICAgICAgIC5maWx0ZXIoY2hlY2sgPT4gY2hlY2subGVuZ3RoICE9PSAwKVxuICAgICAgICAgICAgICAuZm9yRWFjaCgoY2hlY2spID0+IHtcbiAgICAgICAgICAgICAgICBjb25zdCBwYXRoT3V0ID0gW10uY29uY2F0KC4uLnBhdGhJbikuY29uY2F0KGkpO1xuICAgICAgICAgICAgICAgIGlmIChjaGVja1swXSA9PT0gXCIqKlwiKSB7XG4gICAgICAgICAgICAgICAgICByZXN1bHQucHVzaCguLi5maW5kKGhheXN0YWNrW2ldLCBbY2hlY2ssIGNoZWNrLnNsaWNlKDEpXSwgcGF0aE91dCkpO1xuICAgICAgICAgICAgICAgIH0gZWxzZSBpZiAoXG4gICAgICAgICAgICAgICAgICBjaGVja1swXSA9PT0gXCJbKl1cIlxuICAgICAgICAgICAgICAgICAgfHwgY2hlY2tbMF0gPT09IGBbJHtpfV1gXG4gICAgICAgICAgICAgICAgICB8fCAoY2hlY2tbMF0gaW5zdGFuY2VvZiBBcnJheSAmJiBjaGVja1swXS5pbmRleE9mKGBbJHtpfV1gKSAhPT0gLTEpXG4gICAgICAgICAgICAgICAgKSB7XG4gICAgICAgICAgICAgICAgICByZXN1bHQucHVzaCguLi5maW5kKGhheXN0YWNrW2ldLCBbY2hlY2suc2xpY2UoMSldLCBwYXRoT3V0KSk7XG4gICAgICAgICAgICAgICAgfVxuICAgICAgICAgICAgICB9KTtcbiAgICAgICAgICB9XG4gICAgICAgIH0gZWxzZSB7XG4gICAgICAgICAgT2JqZWN0LmtleXMoaGF5c3RhY2spLmZvckVhY2goKGtleSkgPT4ge1xuICAgICAgICAgICAgY2hlY2tzXG4gICAgICAgICAgICAgIC5maWx0ZXIoY2hlY2sgPT4gY2hlY2subGVuZ3RoICE9PSAwKVxuICAgICAgICAgICAgICAuZm9yRWFjaCgoY2hlY2spID0+IHtcbiAgICAgICAgICAgICAgICBjb25zdCBlc2NhcGVkS2V5ID0gZXNjYXBlKGtleSk7XG4gICAgICAgICAgICAgICAgY29uc3QgcGF0aE91dCA9IFtdLmNvbmNhdCguLi5wYXRoSW4pLmNvbmNhdChrZXkpO1xuICAgICAgICAgICAgICAgIGlmIChjaGVja1swXSA9PT0gXCIqKlwiKSB7XG4gICAgICAgICAgICAgICAgICByZXN1bHQucHVzaCguLi5maW5kKGhheXN0YWNrW2tleV0sIFtjaGVjaywgY2hlY2suc2xpY2UoMSldLCBwYXRoT3V0KSk7XG4gICAgICAgICAgICAgICAgfSBlbHNlIGlmIChcbiAgICAgICAgICAgICAgICAgIGNoZWNrWzBdID09PSBcIipcIlxuICAgICAgICAgICAgICAgICAgfHwgY2hlY2tbMF0gPT09IGVzY2FwZWRLZXlcbiAgICAgICAgICAgICAgICAgIHx8IChjaGVja1swXSBpbnN0YW5jZW9mIEFycmF5ICYmIGNoZWNrWzBdLmluZGV4T2YoZXNjYXBlZEtleSkgIT09IC0xKVxuICAgICAgICAgICAgICAgICkge1xuICAgICAgICAgICAgICAgICAgcmVzdWx0LnB1c2goLi4uZmluZChoYXlzdGFja1trZXldLCBbY2hlY2suc2xpY2UoMSldLCBwYXRoT3V0KSk7XG4gICAgICAgICAgICAgICAgfVxuICAgICAgICAgICAgICB9KTtcbiAgICAgICAgICB9KTtcbiAgICAgICAgfVxuICAgICAgfVxuICAgIH1cbiAgICByZXR1cm4gcmVzdWx0O1xuICB9O1xuXG4gIHJldHVybiBoYXlzdGFjayA9PiBmaW5kKGhheXN0YWNrLCBzZWFyY2gpO1xufTtcbiJdfQ==
//# sourceMappingURL=data:application/json;charset=utf-8;base64,eyJ2ZXJzaW9uIjozLCJzb3VyY2VzIjpbIi4uL3NyYy9pbmRleC5qcyJdLCJuYW1lcyI6WyJ1bmlxIiwicmVxdWlyZSIsInBhcnNlciIsImVzY2FwZSIsImlucHV0IiwiU3RyaW5nIiwicmVw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zbGljZSgxKV0sIHBhdGhPdXQsIGN0eCkpO1xuICAgICAgICAgICAgICB9IGVsc2UgaWYgKG1hdGNoZXMoY2hlY2tbMF0sIGBbJHtpfV1gLCB0cnVlLCBjdHgpKSB7XG4gICAgICAgICAgICAgICAgcmVzdWx0LnB1c2goLi4uZmluZChoYXlzdGFja1tpXSwgW2NoZWNrLnNsaWNlKDEpXSwgcGF0aE91dCwgY3R4KSk7XG4gICAgICAgICAgICAgIH1cbiAgICAgICAgICAgIH0pO1xuICAgICAgICB9XG4gICAgICB9IGVsc2Uge1xuICAgICAgICBPYmplY3QuZW50cmllcyhoYXlzdGFjaykuZm9yRWFjaCgoW2tleSwgdmFsdWVdKSA9PiB7XG4gICAgICAgICAgY29uc3QgZXNjYXBlZEtleSA9IGVzY2FwZShrZXkpO1xuICAgICAgICAgIGNvbnN0IHBhdGhPdXQgPSBwYXRoSW4uY29uY2F0KGtleSk7XG4gICAgICAgICAgY2hlY2tzXG4gICAgICAgICAgICAuZmlsdGVyKGNoZWNrID0+IGNoZWNrLmxlbmd0aCAhPT0gMClcbiAgICAgICAgICAgIC5mb3JFYWNoKChjaGVjaykgPT4ge1xuICAgICAgICAgICAgICBpZiAoY2hlY2tbMF0gPT09IFwiKipcIikge1xuICAgICAgICAgICAgICAgIHJlc3VsdC5wdXNoKC4uLmZpbmQodmFsdWUsIFtjaGVjaywgY2hlY2suc2xpY2UoMSldLCBwYXRoT3V0LCBjdHgpKTtcbiAgICAgICAgICAgICAgfSBlbHNlIGlmIChtYXRjaGVzKGNoZWNrWzBdLCBlc2NhcGVkS2V5LCBmYWxzZSwgY3R4KSkge1xuICAgICAgICAgICAgICAgIHJlc3VsdC5wdXNoKC4uLmZpbmQodmFsdWUsIFtjaGVjay5zbGljZSgxKV0sIHBhdGhPdXQsIGN0eCkpO1xuICAgICAgICAgICAgICB9XG4gICAgICAgICAgICB9KTtcbiAgICAgICAgfSk7XG4gICAgICB9XG4gICAgfVxuICB9XG4gIHJldHVybiByZXN1bHQ7XG59O1xuXG5tb2R1bGUuZXhwb3J0cyA9IChuZWVkbGVzLCB7XG4gIGZpbHRlckZuID0gdW5kZWZpbmVkLFxuICBicmVha0ZuID0gdW5kZWZpbmVkLFxuICBqb2luZWQgPSB0cnVlXG59ID0ge30pID0+IHtcbiAgY29uc3Qgc2VhcmNoID0gdW5pcShuZWVkbGVzKS5tYXAocGFyc2VyKTtcbiAgY29uc3QgcmVnZXhDYWNoZSA9IHt9O1xuXG4gIHJldHVybiBoYXlzdGFjayA9PiB1bmlxKGZpbmQoaGF5c3RhY2ssIHNlYXJjaCwgW10sIHtcbiAgICBmaWx0ZXJGbiwgYnJlYWtGbiwgam9pbmVkLCByZWdleENhY2hlXG4gIH0pKTtcbn07XG4iXX0=
{
"name": "object-scan",
"version": "1.2.2",
"version": "1.3.0",
"description": "Find Keys using Wildcard matching and optional value function.",

@@ -28,3 +28,4 @@ "main": "lib/index.js",

"scan",
"find"
"find",
"filter"
],

@@ -39,3 +40,3 @@ "author": "Lukas Siemon",

"babel-cli": "7.0.0-beta.3",
"babel-eslint": "8.2.6",
"babel-eslint": "9.0.0",
"babel-plugin-transform-flow-comments": "7.0.0-beta.3",

@@ -46,5 +47,5 @@ "babel-preset-flow": "7.0.0-beta.3",

"coveralls": "3.0.2",
"js-gardener": "1.30.2",
"nyc": "12.0.2",
"semantic-release": "15.8.1"
"js-gardener": "1.31.4",
"nyc": "13.0.1",
"semantic-release": "15.9.14"
},

@@ -94,4 +95,6 @@ "nyc": {

],
"dependencies": {},
"dependencies": {
"lodash.uniq": "4.5.0"
},
"peerDependencies": {}
}

@@ -5,2 +5,3 @@ # Object-Scan

[![Test Coverage](https://img.shields.io/coveralls/simlu/object-scan/master.svg)](https://coveralls.io/github/simlu/object-scan?branch=master)
[![Dependabot Status](https://api.dependabot.com/badges/status?host=github&repo=simlu/object-scan)](https://dependabot.com)
[![Dependencies](https://david-dm.org/simlu/object-scan/status.svg)](https://david-dm.org/simlu/object-scan)

@@ -31,2 +32,12 @@ [![NPM](https://img.shields.io/npm/v/object-scan.svg)](https://www.npmjs.com/package/object-scan)

### Features
- Object and array matching with e.g. `key.path` and `[1]`
- Key and index wildcard matching with `*` and `[*]`
- Partial key and index wildcard matching, e.g. `mark*` or `[1*]`
- Infinite nested matches with `**`
- Simple or-clause for key and index with `{a,b}` and `[{0,1}]`
- Full support for escaping
- Lots of tests to ensure correctness
### Options

@@ -33,0 +44,0 @@

Sorry, the diff of this file is not supported yet

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