object-rewrite
Advanced tools
Comparing version 4.3.3 to 4.3.4
@@ -32,6 +32,7 @@ "use strict"; | ||
} = options; | ||
return prefix => { | ||
const self = prefix => { | ||
const targetAbs = joinPath([prefix, target]); | ||
let cache; | ||
const result = { | ||
self, | ||
prefix, | ||
@@ -44,12 +45,5 @@ targetNormalized: targetAbs.endsWith('.') ? targetAbs.slice(0, -1) : targetAbs, | ||
type, | ||
init: context => { | ||
cache = {}; | ||
return init === undefined ? true : init({ | ||
context, | ||
cache | ||
}); | ||
}, | ||
fn: (kwargs = {}) => { | ||
// eslint-disable-next-line no-param-reassign | ||
kwargs.cache = cache; | ||
kwargs.cache = self.cache; | ||
return fn(kwargs); | ||
@@ -68,2 +62,12 @@ }, | ||
}; | ||
self.init = context => { | ||
self.cache = {}; | ||
return init === undefined ? true : init({ | ||
context, | ||
cache: self.cache | ||
}); | ||
}; | ||
return self; | ||
}; | ||
@@ -70,0 +74,0 @@ |
@@ -5,6 +5,13 @@ "use strict"; | ||
const result = {}; | ||
Object.entries(map).forEach(([k, v]) => { | ||
result[k] = v.filter(p => p.init(context) === true); | ||
const plugins = new Map(); | ||
Object.entries(map).forEach(([prefix, pls]) => { | ||
result[prefix] = pls.filter(pl => { | ||
if (!plugins.has(pl.self)) { | ||
plugins.set(pl.self, pl.self.init(context)); | ||
} | ||
return plugins.get(pl.self) === true; | ||
}); | ||
}); | ||
return result; | ||
}; |
{ | ||
"name": "object-rewrite", | ||
"version": "4.3.3", | ||
"version": "4.3.4", | ||
"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
23126
404