Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

object-rewrite

Package Overview
Dependencies
Maintainers
1
Versions
179
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

object-rewrite - npm Package Compare versions

Comparing version 4.4.0 to 4.4.1

48

lib/module/plugin.js

@@ -34,3 +34,19 @@ "use strict";

} = options;
let localCache;
let localContext;
const wrap = f => {
if (f === undefined) {
return undefined;
}
return (kwargs = {}) => {
// eslint-disable-next-line no-param-reassign
kwargs.cache = localCache; // eslint-disable-next-line no-param-reassign
kwargs.context = localContext;
return f(kwargs);
};
};
const self = prefix => {

@@ -47,8 +63,4 @@ const targetAbs = joinPath([prefix, target]);

type,
fn: (kwargs = {}) => {
// eslint-disable-next-line no-param-reassign
kwargs.cache = self.cache;
return fn(kwargs);
},
limit
fn: wrap(fn),
limit: wrap(limit)
};

@@ -65,12 +77,20 @@

self.init = context => {
self.cache = {};
return init === undefined ? true : init({
context,
cache: self.cache
});
self.init = (context, logger) => {
if (contextSchema !== undefined && validationCompile(contextSchema, false)(context) === false) {
logger.warn(`Context validation failure\n${JSON.stringify({
origin: 'object-rewrite',
options
})}`);
return false;
}
localCache = {};
localContext = contextSchema instanceof Object && !Array.isArray(contextSchema) ? Object.keys(contextSchema).reduce((p, k) => {
// eslint-disable-next-line no-param-reassign
p[k] = context[k];
return p;
}, {}) : context;
return init === undefined ? true : wrap(init)();
};
self.contextSchema = contextSchema === undefined ? () => true : validationCompile(contextSchema, false);
self.options = options;
return self;

@@ -77,0 +97,0 @@ };

@@ -59,3 +59,2 @@ "use strict";

} = injectRewriter(input, {
context,
injectMap: initPluginMap(injectMap, context, logger),

@@ -69,7 +68,5 @@ promises: []

filterRewriter(input, {
context,
filterMap: initPluginMap(filterMap, context, logger)
});
sortRewriter(input, {
context,
sortMap: initPluginMap(sortMap, context, logger),

@@ -76,0 +73,0 @@ lookups: []

@@ -9,13 +9,3 @@ "use strict";

if (!plugins.has(pl.self)) {
const validContext = pl.self.contextSchema(context);
if (!validContext) {
logger.warn(`Context validation failure\n${JSON.stringify({
origin: 'object-rewrite',
options: pl.self.options
})}`);
plugins.set(pl.self, false);
} else {
plugins.set(pl.self, pl.self.init(context));
}
plugins.set(pl.self, pl.self.init(context, logger));
}

@@ -22,0 +12,0 @@

@@ -29,4 +29,3 @@ "use strict";

value,
parents,
context: context.context
parents
};

@@ -33,0 +32,0 @@ const result = plugins.every(plugin => plugin.fn(kwargs)) === true;

@@ -31,4 +31,3 @@ "use strict";

value,
parents,
context: context.context
parents
};

@@ -35,0 +34,0 @@ const promises = [];

@@ -38,4 +38,3 @@ "use strict";

value,
parents,
context: context.context
parents
};

@@ -42,0 +41,0 @@ lookup.set(value, plugins.map(plugin => plugin.fn(kwargs)));

{
"name": "object-rewrite",
"version": "4.4.0",
"version": "4.4.1",
"description": "Rewrite Object(s) in place using plugins.",

@@ -19,3 +19,3 @@ "main": "lib/index.js",

"@babel/register": "7.12.10",
"@blackflux/eslint-plugin-rules": "1.3.43",
"@blackflux/eslint-plugin-rules": "1.3.44",
"@blackflux/robo-config-plugin": "3.10.17",

@@ -32,3 +32,3 @@ "babel-eslint": "10.1.0",

"eslint-plugin-mocha": "8.0.0",
"js-gardener": "2.0.183",
"js-gardener": "2.0.184",
"lodash.get": "4.4.2",

@@ -35,0 +35,0 @@ "nyc": "15.1.0",

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc