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

object-fields

Package Overview
Dependencies
Maintainers
1
Versions
57
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

object-fields - npm Package Compare versions

Comparing version 2.0.16 to 2.0.17

36

lib/index.js

@@ -43,11 +43,15 @@ "use strict";

const retainer = objectScan(['**'].concat(fields), {
rtn: 'count',
useArraySelector: false,
joined: false,
breakFn: ({
getKey,
getTraversedBy,
matchedBy,
context
parent,
property,
getMatchedBy,
getTraversedBy
}) => {
if (matchedBy.length > 1) {
if (parent === undefined) {
return false;
}
if (getMatchedBy().length > 1) {
// matched by '**' and another needle => keep and break

@@ -57,13 +61,9 @@ return true;

const traversedBy = getTraversedBy();
if (traversedBy.length === 1) {
const key = getKey(); // traversed by only '**' => delete and break
const directParent = key.slice(0, -1).reduce((p, k) => p[k], context.obj);
if (Array.isArray(directParent)) {
directParent.splice(key[key.length - 1], 1);
if (getTraversedBy().length === 1) {
// traversed by only '**' => delete and break
if (Array.isArray(parent)) {
parent.splice(property, 1);
} else {
delete directParent[key[key.length - 1]];
// eslint-disable-next-line no-param-reassign
delete parent[property];
}

@@ -79,6 +79,4 @@

return obj => {
retainer(obj, {
obj
});
retainer(obj);
};
};
{
"name": "object-fields",
"version": "2.0.16",
"version": "2.0.17",
"description": "Utility functions around nested object fields",
"main": "lib/index.js",
"dependencies": {
"object-scan": "13.3.9"
"object-scan": "13.6.6"
},

@@ -13,9 +13,9 @@ "devDependencies": {

"@babel/register": "7.12.1",
"@blackflux/eslint-plugin-rules": "1.3.40",
"@blackflux/robo-config-plugin": "3.10.9",
"@blackflux/eslint-plugin-rules": "1.3.41",
"@blackflux/robo-config-plugin": "3.10.14",
"babel-eslint": "10.1.0",
"chai": "4.2.0",
"coveralls": "3.1.0",
"eslint": "7.11.0",
"eslint-config-airbnb-base": "14.2.0",
"eslint": "7.13.0",
"eslint-config-airbnb-base": "14.2.1",
"eslint-plugin-import": "2.22.1",

@@ -25,6 +25,6 @@ "eslint-plugin-json": "2.1.2",

"eslint-plugin-mocha": "8.0.0",
"js-gardener": "2.0.177",
"js-gardener": "2.0.179",
"nyc": "15.1.0",
"semantic-release": "17.2.1",
"babel-preset-latest-node": "5.0.0"
"semantic-release": "17.2.2",
"babel-preset-latest-node": "5.1.1"
},

@@ -31,0 +31,0 @@ "scripts": {

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