object-scan
Advanced tools
Comparing version 1.6.0 to 1.7.0
@@ -27,9 +27,21 @@ const uniq = require("lodash.uniq"); | ||
const find = (haystack, checks, pathIn, ctx, parents) => { | ||
const slice = array => Object.defineProperty(array.slice(1), "needle", { | ||
value: array.needle, | ||
writable: false | ||
}); | ||
const find = (haystack, checks, pathIn, parents, ctx) => { | ||
const result = []; | ||
const match = checks.find(check => check.length === 0); | ||
if (checks.some(check => check.length === 0)) { | ||
if (ctx.filterFn === undefined || ctx.filterFn(formatPath(pathIn, ctx), haystack, parents) !== false) { | ||
if (match !== undefined) { | ||
if (ctx.excludeFn === undefined || ctx.excludeFn(formatPath(pathIn, ctx), haystack, { | ||
parents, | ||
needle: match.needle | ||
}) !== true) { | ||
if (ctx.callbackFn !== undefined) { | ||
ctx.callbackFn(formatPath(pathIn, ctx), haystack, parents); | ||
ctx.callbackFn(formatPath(pathIn, ctx), haystack, { | ||
parents, | ||
needle: match.needle | ||
}); | ||
} | ||
@@ -41,3 +53,6 @@ | ||
if (ctx.breakFn === undefined || ctx.breakFn(formatPath(pathIn, ctx), haystack, parents) !== true) { | ||
if (ctx.breakFn === undefined || ctx.breakFn(formatPath(pathIn, ctx), haystack, { | ||
parents, | ||
needle: checks[0].needle | ||
}) !== true) { | ||
if (haystack instanceof Object) { | ||
@@ -49,7 +64,7 @@ if (Array.isArray(haystack)) { | ||
if (ctx.useArraySelector === false) { | ||
result.push(...find(haystack[i], [check], pathOut, ctx, parents)); | ||
result.push(...find(haystack[i], [check], pathOut, parents, ctx)); | ||
} else if (check[0] === "**") { | ||
result.push(...find(haystack[i], [check, check.slice(1)], pathOut, ctx, parents.concat([haystack]))); | ||
result.push(...find(haystack[i], [check, slice(check)], pathOut, parents.concat([haystack]), ctx)); | ||
} else if (matches(check[0], `[${i}]`, true, ctx)) { | ||
result.push(...find(haystack[i], [check.slice(1)], pathOut, ctx, parents.concat([haystack]))); | ||
result.push(...find(haystack[i], [slice(check)], pathOut, parents.concat([haystack]), ctx)); | ||
} | ||
@@ -64,5 +79,5 @@ }); | ||
if (check[0] === "**") { | ||
result.push(...find(value, [check, check.slice(1)], pathOut, ctx, parents.concat([haystack]))); | ||
result.push(...find(value, [check, slice(check)], pathOut, parents.concat([haystack]), ctx)); | ||
} else if (matches(check[0], escapedKey, false, ctx)) { | ||
result.push(...find(value, [check.slice(1)], pathOut, ctx, parents.concat([haystack]))); | ||
result.push(...find(value, [slice(check)], pathOut, parents.concat([haystack]), ctx)); | ||
} | ||
@@ -79,3 +94,3 @@ }); | ||
module.exports = (needles, { | ||
filterFn = undefined, | ||
excludeFn = undefined, | ||
breakFn = undefined, | ||
@@ -87,6 +102,9 @@ callbackFn = undefined, | ||
} = {}) => { | ||
const search = uniq(needles).map(parser); | ||
const search = uniq(needles).map(needle => Object.defineProperty(parser(needle), "needle", { | ||
value: needle, | ||
writable: false | ||
})); | ||
const regexCache = {}; | ||
return haystack => uniq(find(haystack, search, [], { | ||
filterFn, | ||
return haystack => uniq(find(haystack, search, [], [], { | ||
excludeFn, | ||
breakFn, | ||
@@ -98,4 +116,4 @@ callbackFn, | ||
useArraySelector | ||
}, [])); | ||
})); | ||
}; | ||
//# sourceMappingURL=data:application/json;charset=utf-8;base64,eyJ2ZXJzaW9uIjozLCJzb3VyY2VzIjpbIi4uL3NyYy9pbmRleC5qcyJdLCJuYW1lcyI6WyJ1bmlxIiwicmVxdWlyZSIsInBhcnNlciIsImVzY2FwZSIsImlucHV0IiwiU3RyaW5nIiwicmVwbGFjZSIsImNvbXBhcmUiLCJ3aWxkY2FyZCIsImFyciIsImN0eCIsIm1hdGNoIiwicmVnZXhDYWNoZSIsInVuZGVmaW5lZCIsIlJlZ0V4cCIsInNwbGl0IiwibWFwIiwicCIsImpvaW4iLCJtYXRjaGVzIiwiQXJyYXkiLCJpc0FycmF5Iiwic29tZSIsIndjIiwiZm9ybWF0UGF0aCIsImpvaW5lZCIsInJlZHVjZSIsImMiLCJpc051bWJlciIsImVzY2FwZVBhdGhzIiwiZmluZ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hbHNlKSB7XG4gICAgICAgICAgICAgICAgcmVzdWx0LnB1c2goLi4uZmluZChoYXlzdGFja1tpXSwgW2NoZWNrXSwgcGF0aE91dCwgY3R4LCBwYXJlbnRzKSk7XG4gICAgICAgICAgICAgIH0gZWxzZSBpZiAoY2hlY2tbMF0gPT09IFwiKipcIikge1xuICAgICAgICAgICAgICAgIHJlc3VsdC5wdXNoKC4uLmZpbmQoaGF5c3RhY2tbaV0sIFtjaGVjaywgY2hlY2suc2xpY2UoMSldLCBwYXRoT3V0LCBjdHgsIHBhcmVudHMuY29uY2F0KFtoYXlzdGFja10pKSk7XG4gICAgICAgICAgICAgIH0gZWxzZSBpZiAobWF0Y2hlcyhjaGVja1swXSwgYFske2l9XWAsIHRydWUsIGN0eCkpIHtcbiAgICAgICAgICAgICAgICByZXN1bHQucHVzaCguLi5maW5kKGhheXN0YWNrW2ldLCBbY2hlY2suc2xpY2UoMSldLCBwYXRoT3V0LCBjdHgsIHBhcmVudHMuY29uY2F0KFtoYXlzdGFja10pKSk7XG4gICAgICAgICAgICAgIH1cbiAgICAgICAgICAgIH0pO1xuICAgICAgICB9XG4gICAgICB9IGVsc2Uge1xuICAgICAgICBPYmplY3QuZW50cmllcyhoYXlzdGFjaykuZm9yRWFjaCgoW2tleSwgdmFsdWVdKSA9PiB7XG4gICAgICAgICAgY29uc3QgZXNjYXBlZEtleSA9IGVzY2FwZShrZXkpO1xuICAgICAgICAgIGNvbnN0IHBhdGhPdXQgPSBwYXRoSW4uY29uY2F0KGtleSk7XG4gICAgICAgICAgY2hlY2tzXG4gICAgICAgICAgICAuZmlsdGVyKGNoZWNrID0+IGNoZWNrLmxlbmd0aCAhPT0gMClcbiAgICAgICAgICAgIC5mb3JFYWNoKChjaGVjaykgPT4ge1xuICAgICAgICAgICAgICBpZiAoY2hlY2tbMF0gPT09IFwiKipcIikge1xuICAgICAgICAgICAgICAgIHJlc3VsdC5wdXNoKC4uLmZpbmQodmFsdWUsIFtjaGVjaywgY2hlY2suc2xpY2UoMSldLCBwYXRoT3V0LCBjdHgsIHBhcmVudHMuY29uY2F0KFtoYXlzdGFja10pKSk7XG4gICAgICAgICAgICAgIH0gZWxzZSBpZiAobWF0Y2hlcyhjaGVja1swXSwgZXNjYXBlZEtleSwgZmFsc2UsIGN0eCkpIHtcbiAgICAgICAgICAgICAgICByZXN1bHQucHVzaCguLi5maW5kKHZhbHVlLCBbY2hlY2suc2xpY2UoMSldLCBwYXRoT3V0LCBjdHgsIHBhcmVudHMuY29uY2F0KFtoYXlzdGFja10pKSk7XG4gICAgICAgICAgICAgIH1cbiAgICAgICAgICAgIH0pO1xuICAgICAgICB9KTtcbiAgICAgIH1cbiAgICB9XG4gIH1cbiAgcmV0dXJuIHJlc3VsdDtcbn07XG5cbm1vZHVsZS5leHBvcnRzID0gKG5lZWRsZXMsIHtcbiAgZmlsdGVyRm4gPSB1bmRlZmluZWQsXG4gIGJyZWFrRm4gPSB1bmRlZmluZWQsXG4gIGNhbGxiYWNrRm4gPSB1bmRlZmluZWQsXG4gIGpvaW5lZCA9IHRydWUsXG4gIGVzY2FwZVBhdGhzID0gdHJ1ZSxcbiAgdXNlQXJyYXlTZWxlY3RvciA9IHRydWVcbn0gPSB7fSkgPT4ge1xuICBjb25zdCBzZWFyY2ggPSB1bmlxKG5lZWRsZXMpLm1hcChwYXJzZXIpO1xuICBjb25zdCByZWdleENhY2hlID0ge307XG5cbiAgcmV0dXJuIGhheXN0YWNrID0+IHVuaXEoZmluZChoYXlzdGFjaywgc2VhcmNoLCBbXSwge1xuICAgIGZpbHRlckZuLCBicmVha0ZuLCBjYWxsYmFja0ZuLCBqb2luZWQsIHJlZ2V4Q2FjaGUsIGVzY2FwZVBhdGhzLCB1c2VBcnJheVNlbGVjdG9yXG4gIH0sIFtdKSk7XG59O1xuIl19 | ||
//# sourceMappingURL=data:application/json;charset=utf-8;base64,eyJ2ZXJzaW9uIjozLCJzb3VyY2VzIjpbIi4uL3NyYy9pbmRleC5qcyJdLCJuYW1l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zdCBwYXRoT3V0ID0gcGF0aEluLmNvbmNhdChpKTtcbiAgICAgICAgICBjaGVja3NcbiAgICAgICAgICAgIC5maWx0ZXIoY2hlY2sgPT4gY2hlY2subGVuZ3RoICE9PSAwKVxuICAgICAgICAgICAgLmZvckVhY2goKGNoZWNrKSA9PiB7XG4gICAgICAgICAgICAgIGlmIChjdHgudXNlQXJyYXlTZWxlY3RvciA9PT0gZmFsc2UpIHtcbiAgICAgICAgICAgICAgICByZXN1bHQucHVzaCguLi5maW5kKGhheXN0YWNrW2ldLCBbY2hlY2tdLCBwYXRoT3V0LCBwYXJlbnRzLCBjdHgpKTtcbiAgICAgICAgICAgICAgfSBlbHNlIGlmIChjaGVja1swXSA9PT0gXCIqKlwiKSB7XG4gICAgICAgICAgICAgICAgcmVzdWx0LnB1c2goLi4uZmluZChoYXlzdGFja1tpXSwgW2NoZWNrLCBzbGljZShjaGVjayldLCBwYXRoT3V0LCBwYXJlbnRzLmNvbmNhdChbaGF5c3RhY2tdKSwgY3R4KSk7XG4gICAgICAgICAgICAgIH0gZWxzZSBpZiAobWF0Y2hlcyhjaGVja1swXSwgYFske2l9XWAsIHRydWUsIGN0eCkpIHtcbiAgICAgICAgICAgICAgICByZXN1bHQucHVzaCguLi5maW5kKGhheXN0YWNrW2ldLCBbc2xpY2UoY2hlY2spXSwgcGF0aE91dCwgcGFyZW50cy5jb25jYXQoW2hheXN0YWNrXSksIGN0eCkpO1xuICAgICAgICAgICAgICB9XG4gICAgICAgICAgICB9KTtcbiAgICAgICAgfVxuICAgICAgfSBlbHNlIHtcbiAgICAgICAgT2JqZWN0LmVudHJpZXMoaGF5c3RhY2spLmZvckVhY2goKFtrZXksIHZhbHVlXSkgPT4ge1xuICAgICAgICAgIGNvbnN0IGVzY2FwZWRLZXkgPSBlc2NhcGUoa2V5KTtcbiAgICAgICAgICBjb25zdCBwYXRoT3V0ID0gcGF0aEluLmNvbmNhdChrZXkpO1xuICAgICAgICAgIGNoZWNrc1xuICAgICAgIC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dleENhY2hlID0ge307XG5cbiAgcmV0dXJuIGhheXN0YWNrID0+IHVuaXEoZmluZChoYXlzdGFjaywgc2VhcmNoLCBbXSwgW10sIHtcbiAgICBleGNsdWRlRm4sXG4gICAgYnJlYWtGbixcbiAgICBjYWxsYmFja0ZuLFxuICAgIGpvaW5lZCxcbiAgICByZWdleENhY2hlLFxuICAgIGVzY2FwZVBhdGhzLFxuICAgIHVzZUFycmF5U2VsZWN0b3JcbiAgfSkpO1xufTtcbiJdfQ== |
{ | ||
"name": "object-scan", | ||
"version": "1.6.0", | ||
"version": "1.7.0", | ||
"description": "Find Keys using Wildcard matching and optional value function.", | ||
@@ -5,0 +5,0 @@ "main": "lib/index.js", |
@@ -45,7 +45,9 @@ # Object-Scan | ||
**Note on Functions:** | ||
Signature for all functions is `Fn(key, value, parents)`, where `key` is the key that the function is called for, | ||
`value` is the value of that key and `parents` is an array containing all parents as `[..., grandparent, parent]`. | ||
The `key` argument respects the `joined` option and the `parents` only includes arrays if `useArraySelector` is true. | ||
Signature for all functions is `Fn(key, value, { parents, needle })`, where: | ||
- `key` is the key that the function is called for (respects `joined` option). | ||
- `value` is the value of that key. | ||
- `parents` is an array containing all parents as `[..., grandparent, parent]` (includes arrays iff `useArraySelector` is true). | ||
- `needle` is a needle that triggered the function call. | ||
#### filterFn | ||
#### excludeFn | ||
@@ -56,3 +58,3 @@ Type: `function`<br> | ||
Called for every intermittent result. | ||
If function is defined and returns false, the entry is filtered from the final result. | ||
If function is defined and returns true, the entry is excluded from the final result. | ||
@@ -64,4 +66,4 @@ #### breakFn | ||
Called for every intermittent result. | ||
If function is defined and returns true, all nested entries under the current key are excluded from the result. | ||
Called for every potential (partial) result at least once. | ||
If function is defined and returns true, all nested entries under the current key are excluded from search and from the final result. | ||
@@ -150,3 +152,3 @@ #### callbackFn | ||
// value function | ||
objectScan(["**"], { filterFn: (key, value) => typeof value === "string" })(obj); | ||
objectScan(["**"], { excludeFn: (key, value) => typeof value !== "string" })(obj); | ||
// => ["a.b.c", "a.e.f", "a.h[0]", "a.h[1]", "k"] | ||
@@ -153,0 +155,0 @@ objectScan(["**"], { breakFn: key => key === "a.b" })(obj); |
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
28762
111
161