object-rewrite
Advanced tools
Comparing version 1.0.3 to 1.0.4
@@ -10,6 +10,6 @@ const assert = require("assert"); | ||
inject = {}, | ||
include = ["**"] | ||
retain = ["**"] | ||
}) => { | ||
const needles = [...Object.keys(exclude), ...Object.keys(inject), ...include]; | ||
const included = []; | ||
const needles = [...Object.keys(exclude), ...Object.keys(inject), ...retain]; | ||
const retained = []; | ||
const excluded = []; | ||
@@ -26,4 +26,4 @@ const scanner = objectScan(needles, { | ||
if (include.includes(needle)) { | ||
included.push(key); | ||
if (retain.includes(needle)) { | ||
retained.push(key); | ||
} | ||
@@ -42,7 +42,7 @@ | ||
scanner(input); | ||
tree.prune(input, included, excluded); | ||
included.length = 0; | ||
tree.prune(input, retained, excluded); | ||
retained.length = 0; | ||
excluded.length = 0; | ||
}; | ||
}; | ||
//# sourceMappingURL=data:application/json;charset=utf-8;base64,eyJ2ZXJzaW9uIjozLCJzb3VyY2VzIjpbIi4uL3NyYy9pbmRleC5qcyJdLCJuYW1lcyI6WyJhc3NlcnQiLCJyZXF1aXJlIiwib2JqZWN0U2NhbiIsInRyZWUiLCJtb2R1bGUiLCJleHBvcnRzIiwiZXhjbHVkZSIsImluamVjdCIsImluY2x1ZGUiLCJuZWVkbGVzIiwiT2JqZWN0Iiwia2V5cyIsImluY2x1ZGVkIiwiZXhjbHVkZWQiLCJzY2FubmVyIiwidXNlQXJyYXlTZWxlY3RvciIsImpvaW5lZCIsImNhbGxiYWNrRm4iLCJrZXkiLCJ2YWx1ZSIsImlzTWF0Y2giLCJuZWVkbGUiLCJwYXJlbnRzIiwiaW5jbHVkZXMiLCJwdXNoIiwidW5kZWZpbmVkIiwiYXNzaWduIiwiaW5wdXQiLCJwcnVuZSIsImxlbmd0aCJdLCJtYXBwaW5ncyI6IkFBQUEsTUFBTUEsU0FBU0MsUUFBUSxRQUFSLENBQWY7O0FBQ0EsTUFBTUMsYUFBYUQsUUFBUSxhQUFSLENBQW5COztBQUNBLE1BQU1FLE9BQU9GLFFBQVEsYU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gIGNvbnN0IHNjYW5uZXIgPSBvYmplY3RTY2FuKG5lZWRsZXMsIHtcbiAgICB1c2VBcnJheVNlbGVjdG9yOiBmYWxzZSxcbiAgICBqb2luZWQ6IGZhbHNlLFxuICAgIGNhbGxiYWNrRm46IChrZXksIHZhbHVlLCB7IGlzTWF0Y2gsIG5lZWRsZSwgcGFyZW50cyB9KSA9PiB7XG4gICAgICBhc3NlcnQoaXNNYXRjaCA9PT0gdHJ1ZSk7XG4gICAgICBpZiAocmV0YWluLmluY2x1ZGVzKG5lZWRsZSkpIHtcbiAgICAgICAgcmV0YWluZWQucHVzaChrZXkpO1xuICAgICAgfVxuICAgICAgaWYgKGV4Y2x1ZGVbbmVlZGxlXSAhPT0gdW5kZWZpbmVkICYmIGV4Y2x1ZGVbbmVlZGxlXShrZXksIHZhbHVlLCBwYXJlbnRzKSA9PT0gdHJ1ZSkge1xuICAgICAgICBleGNsdWRlZC5wdXNoKGtleSk7XG4gICAgICB9XG4gICAgICBpZiAoaW5qZWN0W25lZWRsZV0gIT09IHVuZGVmaW5lZCkge1xuICAgICAgICBPYmplY3QuYXNzaWduKHZhbHVlLCBpbmplY3RbbmVlZGxlXShrZXksIHZhbHVlLCBwYXJlbnRzKSk7XG4gICAgICB9XG4gICAgfVxuICB9KTtcblxuICByZXR1cm4gKGlucHV0KSA9PiB7XG4gICAgc2Nhbm5lcihpbnB1dCk7XG4gICAgdHJlZS5wcnVuZShpbnB1dCwgcmV0YWluZWQsIGV4Y2x1ZGVkKTtcbiAgICByZXRhaW5lZC5sZW5ndGggPSAwO1xuICAgIGV4Y2x1ZGVkLmxlbmd0aCA9IDA7XG4gIH07XG59O1xuIl19 |
@@ -26,3 +26,3 @@ const LEAF = Symbol("leaf"); | ||
const pruneRec = (input, include, exclude) => { | ||
const pruneRec = (input, retain, exclude) => { | ||
const isArray = Array.isArray(input); | ||
@@ -37,3 +37,3 @@ const inputEntries = Object.entries(input); | ||
inputEntries.forEach(([key, value]) => { | ||
if (exclude[key] !== undefined && isLeaf(exclude[key]) || include[key] === undefined) { | ||
if (exclude[key] !== undefined && isLeaf(exclude[key]) || retain[key] === undefined) { | ||
if (isArray) { | ||
@@ -46,3 +46,3 @@ input.splice(key, 1); | ||
} else { | ||
pruneRec(value, include[key], exclude[key] || {}); | ||
pruneRec(value, retain[key], exclude[key] || {}); | ||
} | ||
@@ -52,5 +52,5 @@ }); | ||
module.exports.prune = (input, include, exclude) => { | ||
pruneRec(input, build(include), build(exclude)); | ||
module.exports.prune = (input, retain, exclude) => { | ||
pruneRec(input, build(retain), build(exclude)); | ||
}; | ||
//# sourceMappingURL=data:application/json;charset=utf-8;base64,eyJ2ZXJzaW9uIjozLCJzb3VyY2VzIjpbIi4uLy4uL3NyYy91dGlsL3RyZWUuanMiXSwibmFtZXMiOlsiTEVBRiIsIlN5bWJvbCIsIm1hcmtMZWFmIiwiaW5wdXQiLCJPYmplY3QiLCJkZWZpbmVQcm9wZXJ0eSIsInZhbHVlIiwid3JpdGFibGUiLCJpc0xlYWYiLCJidWlsZCIsIm5lZWRsZXMiLCJyZXN1bHQiLCJmb3JFYWNoIiwiYnJhbmNoIiwiZWxlIiwic2VnIiwidW5kZWZpbmVkIiwicHJ1bmVSZWMiLCJpbmNsdWRlIiwiZXhjbHVkZSIsImlzQXJyYXkiLCJBcnJheSIsImlucHV0RW50cmllcyIsImVudHJpZXMiLCJzb3J0IiwiYSIsImIiLCJwYXJzZUludCIsImtleSIsInNwbGljZSIsIm1vZHVsZSIsImV4cG9ydHMiLCJwcnVuZSJdLCJtYXBwaW5ncyI6IkFBQUEsTUFBTUEsT0FBT0MsT0FBTyxNQUFQLENBQWI7O0FBRUEsTUFBTUMsV0FBV0MsU0FBU0MsT0FBT0MsY0FBUCxDQUFzQkYsS0FBdEIsRUFBNkJILElBQTdCLEVBQW1DO0FBQUVNLFNBQU8sSUFBVDtBQUFlQyxZQUFVO0FBQXpCLENBQW5DLENBQTFCOztBQUNBLE1BQU1DLFNBQVNMLFNBQVN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HVkZSkpO1xufTtcbiJdfQ== |
{ | ||
"name": "object-rewrite", | ||
"version": "1.0.3", | ||
"version": "1.0.4", | ||
"description": "Rewrite an Object", | ||
@@ -5,0 +5,0 @@ "main": "lib/index.js", |
@@ -12,3 +12,3 @@ [![Build Status](https://circleci.com/gh/blackflux/object-rewrite.png?style=shield)](https://circleci.com/gh/blackflux/object-rewrite) | ||
Rewrite an Object by defining exactly what gets excluded, injected and included. | ||
Rewrite an Object by defining exactly what gets excluded, injected and retained. | ||
@@ -54,3 +54,3 @@ ## Install | ||
}, | ||
include: ["count", "active", "tags.id"] | ||
retain: ["count", "active", "tags.id"] | ||
}); | ||
@@ -92,4 +92,4 @@ | ||
### Include | ||
### Retain | ||
Array of needles. Matches are kept if not excluded previously. All entries not matched are excluded. |
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
16525