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.3.0 to 4.3.1

8

lib/module/plugin.js

@@ -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);

{
"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",

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