object-rewrite
Advanced tools
Comparing version 6.0.3 to 6.0.4
@@ -56,4 +56,26 @@ "use strict"; | ||
const wrapInject = f => { | ||
const schema = validationCompile(fnSchema); | ||
const validate = r => { | ||
if (schema(r) !== true) { | ||
throw new Error(`${name}: bad fn return value "${r}"`); | ||
} | ||
return r; | ||
}; | ||
return kwargs => { | ||
const result = f(kwargs); | ||
if (result instanceof Promise) { | ||
return result.then(r => validate(r)); | ||
} | ||
return validate(result); | ||
}; | ||
}; | ||
const fnWrapped = (() => { | ||
const wrapped = wrap(fn); | ||
const wrapped = type === 'INJECT' ? wrapInject(wrap(fn)) : wrap(fn); | ||
@@ -96,3 +118,2 @@ if (valueSchema === undefined) { | ||
result.targetNormalized = prefix; | ||
result.fnSchema = validationCompile(fnSchema); | ||
result.targets = validationExtractKeys(targetAbs, fnSchema); | ||
@@ -99,0 +120,0 @@ } |
@@ -36,4 +36,2 @@ "use strict"; | ||
const exec = r => { | ||
assert(plugin.fnSchema(r) === true, r); | ||
if (plugin.targetRel === '*') { | ||
@@ -40,0 +38,0 @@ Object.assign(kwargs.value, r); |
{ | ||
"name": "object-rewrite", | ||
"version": "6.0.3", | ||
"version": "6.0.4", | ||
"description": "Rewrite Object(s) in place using plugins.", | ||
@@ -34,3 +34,3 @@ "main": "lib/index.js", | ||
"nyc": "15.1.0", | ||
"semantic-release": "17.3.9" | ||
"semantic-release": "17.4.0" | ||
}, | ||
@@ -37,0 +37,0 @@ "scripts": { |
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
25660
471