object-rewrite
Advanced tools
@@ -50,5 +50,7 @@ "use strict"; | ||
| }, | ||
| fn: kwargs => fn({ ...kwargs, | ||
| cache | ||
| }), | ||
| fn: (kwargs = {}) => { | ||
| // eslint-disable-next-line no-param-reassign | ||
| kwargs.cache = cache; | ||
| return fn(kwargs); | ||
| }, | ||
| limit | ||
@@ -55,0 +57,0 @@ }; |
| "use strict"; | ||
| const assert = require('assert'); | ||
| const objectScan = require('object-scan'); | ||
@@ -10,11 +12,19 @@ | ||
| filterFn: ({ | ||
| key, | ||
| value, | ||
| parents, | ||
| property, | ||
| parent, | ||
| matchedBy, | ||
| getKey, | ||
| getValue, | ||
| getParents, | ||
| context | ||
| }) => { | ||
| const result = matchedBy.some(m => execPlugins('FILTER', context.filterMap[m], { | ||
| assert(matchedBy.length === 1); | ||
| const plugins = context.filterMap[matchedBy[0]]; | ||
| if (plugins.length === 0) { | ||
| return true; | ||
| } | ||
| const key = getKey(); | ||
| const value = getValue(); | ||
| const parents = getParents(); | ||
| const result = execPlugins('FILTER', plugins, { | ||
| key, | ||
@@ -24,10 +34,9 @@ value, | ||
| context: context.context | ||
| }) === true); | ||
| }) === true; | ||
| if (result === false) { | ||
| if (Array.isArray(parent)) { | ||
| parent.splice(property, 1); | ||
| if (Array.isArray(parents[0])) { | ||
| parents[0].splice(key[key.length - 1], 1); | ||
| } else { | ||
| // eslint-disable-next-line no-param-reassign | ||
| delete parent[property]; | ||
| delete parents[0][key[key.length - 1]]; | ||
| } | ||
@@ -34,0 +43,0 @@ } |
| "use strict"; | ||
| const assert = require('assert'); | ||
| const objectScan = require('object-scan'); | ||
@@ -10,19 +12,27 @@ | ||
| filterFn: ({ | ||
| key, | ||
| value, | ||
| parents, | ||
| matchedBy, | ||
| getKey, | ||
| getValue, | ||
| getParents, | ||
| context | ||
| }) => { | ||
| matchedBy.forEach(m => { | ||
| const promises = execPlugins('INJECT', context.injectMap[m], { | ||
| key, | ||
| value, | ||
| parents, | ||
| context: context.context | ||
| }); | ||
| context.promises.push(...promises); | ||
| assert(matchedBy.length === 1); | ||
| const plugins = context.injectMap[matchedBy[0]]; | ||
| if (plugins.length === 0) { | ||
| return true; | ||
| } | ||
| const key = getKey(); | ||
| const value = getValue(); | ||
| const parents = getParents(); | ||
| const promises = execPlugins('INJECT', plugins, { | ||
| key, | ||
| value, | ||
| parents, | ||
| context: context.context | ||
| }); | ||
| context.promises.push(...promises); | ||
| return true; | ||
| } | ||
| }); |
@@ -14,8 +14,18 @@ "use strict"; | ||
| filterFn: ({ | ||
| key, | ||
| value, | ||
| parents, | ||
| matchedBy, | ||
| getKey, | ||
| getValue, | ||
| getParents, | ||
| context | ||
| }) => { | ||
| assert(matchedBy.length === 1); | ||
| const plugins = context.sortMap[matchedBy[0]]; | ||
| if (plugins.length === 0) { | ||
| return true; | ||
| } | ||
| const key = getKey(); | ||
| const value = getValue(); | ||
| const parents = getParents(); | ||
| assert(Array.isArray(parents[0]), 'Sort must be on "Array" type.'); | ||
@@ -28,3 +38,3 @@ | ||
| const lookup = context.lookups[key.length - 1]; | ||
| lookup.set(value, execPlugins('SORT', context.sortMap[matchedBy[0]], { | ||
| lookup.set(value, execPlugins('SORT', plugins, { | ||
| key, | ||
@@ -38,3 +48,3 @@ value, | ||
| parents[0].sort((a, b) => cmpFn(lookup.get(a), lookup.get(b))); | ||
| const limits = context.sortMap[matchedBy[0]].filter(p => p.limit !== undefined).map(p => p.limit({ | ||
| const limits = plugins.filter(p => p.limit !== undefined).map(p => p.limit({ | ||
| context: context.context | ||
@@ -41,0 +51,0 @@ })).filter(l => l !== undefined); |
+1
-1
| { | ||
| "name": "object-rewrite", | ||
| "version": "4.3.0", | ||
| "version": "4.3.1", | ||
| "description": "Rewrite Object(s) in place using plugins.", | ||
@@ -5,0 +5,0 @@ "main": "lib/index.js", |
Major refactor
Supply chain riskPackage has recently undergone a major refactor. It may be unstable or indicate significant internal changes. Use caution when updating to versions that include significant changes.
Found 1 instance in 1 package
23250
3.15%405
6.02%0
-100%