object-rewrite
Advanced tools
Comparing version 4.3.1 to 4.3.2
@@ -7,4 +7,2 @@ "use strict"; | ||
const execPlugins = require('./exec-plugins'); | ||
module.exports = keys => objectScan(keys, { | ||
@@ -29,3 +27,3 @@ useArraySelector: false, | ||
const parents = getParents(); | ||
const result = execPlugins('FILTER', plugins, { | ||
const kwargs = { | ||
key, | ||
@@ -35,3 +33,4 @@ value, | ||
context: context.context | ||
}) === true; | ||
}; | ||
const result = plugins.every(plugin => plugin.fn(kwargs)) === true; | ||
@@ -38,0 +37,0 @@ if (result === false) { |
@@ -7,3 +7,3 @@ "use strict"; | ||
const execPlugins = require('./exec-plugins'); | ||
const set = require('lodash.set'); | ||
@@ -29,3 +29,3 @@ module.exports = keys => objectScan(keys, { | ||
const parents = getParents(); | ||
const promises = execPlugins('INJECT', plugins, { | ||
const kwargs = { | ||
key, | ||
@@ -35,2 +35,22 @@ value, | ||
context: context.context | ||
}; | ||
const promises = []; | ||
plugins.forEach(plugin => { | ||
const exec = r => { | ||
assert(plugin.schema(r) === true); | ||
if (plugin.targetRel === '*') { | ||
Object.assign(kwargs.value, r); | ||
} else { | ||
set(kwargs.value, plugin.targetRel, r); | ||
} | ||
}; | ||
const result = plugin.fn(kwargs); | ||
if (result instanceof Promise) { | ||
promises.push(async () => exec(await result)); | ||
} else { | ||
exec(result); | ||
} | ||
}); | ||
@@ -37,0 +57,0 @@ context.promises.push(...promises); |
@@ -7,4 +7,2 @@ "use strict"; | ||
const execPlugins = require('./exec-plugins'); | ||
const cmpFn = require('../../util/cmp-fn'); | ||
@@ -38,3 +36,3 @@ | ||
const lookup = context.lookups[key.length - 1]; | ||
lookup.set(value, execPlugins('SORT', plugins, { | ||
const kwargs = { | ||
key, | ||
@@ -44,3 +42,4 @@ value, | ||
context: context.context | ||
})); | ||
}; | ||
lookup.set(value, plugins.map(plugin => plugin.fn(kwargs))); | ||
@@ -47,0 +46,0 @@ if (key[key.length - 1] === 0) { |
{ | ||
"name": "object-rewrite", | ||
"version": "4.3.1", | ||
"version": "4.3.2", | ||
"description": "Rewrite Object(s) in place using plugins.", | ||
@@ -5,0 +5,0 @@ "main": "lib/index.js", |
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
22777
16
393