object-rewrite
Advanced tools
Comparing version 2.1.4 to 2.1.5
@@ -14,6 +14,3 @@ const assert = require('assert'); | ||
}) => { | ||
const needles = [...Object.keys(filter), ...Object.keys(inject), ...Object.keys(overwrite), ...retain]; | ||
const toRemove = []; | ||
const toRetain = []; | ||
const scanner = objectScan(needles, { | ||
const scannerInjectAndOverwrite = objectScan(Object.keys(inject).concat(Object.keys(overwrite)), { | ||
useArraySelector: false, | ||
@@ -26,13 +23,3 @@ joined: false, | ||
}) => { | ||
assert(isMatch === true); | ||
matchedBy.sort(); | ||
if (matchedBy.some(n => filter[n] !== undefined && filter[n](key, value, parents) === false)) { | ||
toRemove.push(key); | ||
} | ||
if (matchedBy.some(n => retain.includes(n))) { | ||
toRetain.push(key); | ||
} | ||
matchedBy.forEach(n => { | ||
@@ -51,2 +38,23 @@ if (inject[n] !== undefined) { | ||
}); | ||
} | ||
}); | ||
const toRemove = []; | ||
const toRetain = []; | ||
const scannerRemoveAndRetain = objectScan(Object.keys(filter).concat(retain), { | ||
useArraySelector: false, | ||
joined: false, | ||
callbackFn: (key, value, { | ||
isMatch, | ||
matchedBy, | ||
parents | ||
}) => { | ||
assert(isMatch === true); | ||
if (matchedBy.some(n => filter[n] !== undefined && filter[n](key, value, parents) === false)) { | ||
toRemove.push(key); | ||
} | ||
if (matchedBy.some(n => retain.includes(n))) { | ||
toRetain.push(key); | ||
} | ||
}, | ||
@@ -71,3 +79,4 @@ arrayCallbackFn: (key, value, { | ||
return input => { | ||
scanner(input); | ||
scannerInjectAndOverwrite(input); | ||
scannerRemoveAndRetain(input); | ||
tree.prune(input, toRemove, toRetain); | ||
@@ -78,2 +87,2 @@ toRemove.length = 0; | ||
}; | ||
//# sourceMappingURL=data:application/json;charset=utf-8;base64,eyJ2ZXJzaW9uIjozLCJzb3VyY2VzIjpbIi4uL3NyYy9pbmRleC5qcyJdLCJuYW1lcyI6WyJhc3NlcnQiLCJyZXF1aXJlIiwib2JqZWN0U2NhbiIsInRyZWUiLCJtb2R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biAgICB0b1JlbW92ZS5sZW5ndGggPSAwO1xuICAgIHRvUmV0YWluLmxlbmd0aCA9IDA7XG4gIH07XG59O1xuIl19 |
{ | ||
"name": "object-rewrite", | ||
"version": "2.1.4", | ||
"version": "2.1.5", | ||
"description": "Rewrite an Object", | ||
@@ -10,3 +10,3 @@ "main": "lib/index.js", | ||
"dependencies": { | ||
"object-scan": "3.0.0" | ||
"object-scan": "3.1.0" | ||
}, | ||
@@ -17,3 +17,3 @@ "devDependencies": { | ||
"coveralls": "3.0.3", | ||
"js-gardener": "1.37.4", | ||
"js-gardener": "1.37.5", | ||
"nyc": "13.3.0", | ||
@@ -20,0 +20,0 @@ "semantic-release": "15.13.3", |
@@ -46,6 +46,2 @@ # object-rewrite | ||
const rewriter = objectRewrite({ | ||
filter: { | ||
'': (key, value, parents) => value.active === 'yes', | ||
tags: (key, value, parents) => value.id === 4 | ||
}, | ||
inject: { | ||
@@ -57,2 +53,6 @@ '': (key, value, parents) => ({ countNext: value.count + 1 }) | ||
}, | ||
filter: { | ||
'': (key, value, parents) => value.active === true, | ||
tags: (key, value, parents) => value.id === 4 | ||
}, | ||
retain: ['count', 'countNext', 'active', 'tags.id'] | ||
@@ -89,6 +89,4 @@ }); | ||
### Filter | ||
Execution order happens as follows: inject and overwrite (where inject happens before overwrite on a key bases) and then filter and retain as a separate pass on the modified data. | ||
Takes object where keys are needles and values are functions. The matches for a needle are removed from the object iff the corresponding function execution returns false. | ||
### Inject | ||
@@ -102,2 +100,6 @@ | ||
### Filter | ||
Takes object where keys are needles and values are functions. The matches for a needle are removed from the object iff the corresponding function execution returns false. | ||
### Retain | ||
@@ -104,0 +106,0 @@ |
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
24017
120
118
+ Addedobject-scan@3.1.0(transitive)
- Removedobject-scan@3.0.0(transitive)
Updatedobject-scan@3.1.0