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

deepdash

Package Overview
Dependencies
Maintainers
1
Versions
112
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

deepdash - npm Package Compare versions

Comparing version 1.7.0 to 1.7.1

2

deepdash.js

@@ -277,2 +277,3 @@ 'use strict';

cloneDeep: _.cloneDeep,
pathFormat: 'string',
},

@@ -283,2 +284,3 @@ options || {}

track: options.checkCircular,
pathFormat: options.pathFormat,
};

@@ -285,0 +287,0 @@ var res = _.isArray(obj) ? [] : {};

2

package.json
{
"name": "deepdash",
"version": "1.7.0",
"version": "1.7.1",
"description": "Object tree traversal for lodash",

@@ -5,0 +5,0 @@ "main": "deepdash.js",

@@ -272,2 +272,5 @@ <img src="deepdash.svg?sanitize=true" width="64px"/>

cloneDeep: _.cloneDeep, // Method to use for deep cloning values, lodash cloneDeep by default.
pathFormat: 'string', /* 'string'|'array' - specifies the format of paths passed to the iteratee.
'array' is better for performance.
It also works better with Lodash.get/set/has, if field names contain `."][` characters. */
}

@@ -274,0 +277,0 @@ )

@@ -76,2 +76,27 @@ 'use strict';

it('circular with array path format', () => {
let circluarPath = [];
_.eachDeep(
circular,
(value, key, path, depth, parent, parentKey, parentPath, parents) => {
parents.paths.forEach((p) => {
expect(p).to.be.an.array();
});
if (parents.values.indexOf(value) != -1) {
circluarPath.push(_.pathToString(path));
return false;
}
},
{ track: true, pathFormat: 'array' }
);
expect(circluarPath)
.to.include('a.b.c.e')
.and.to.include('i[5][0]')
.and.to.include('i[5][1][0].b.c.e')
.and.to.have.property('length')
.and.equal(3);
});
it('Array', () => {

@@ -78,0 +103,0 @@ let c = 0;

@@ -165,2 +165,94 @@ 'use strict';

});
it('array path format', () => {
const input = [
{
value: 'Miss1',
children: [
{ value: 'Miss2' },
{ value: 'Hit1', children: [{ value: 'Miss3' }] },
],
},
{
value: 'Miss4',
children: [
{ value: 'Miss5' },
{ value: 'Miss6', children: [{ value: 'Hit2' }] },
],
},
{
value: 'Miss7',
children: [
{ value: 'Miss8' },
{ value: 'Miss9', children: [{ value: 'Miss10' }] },
],
},
{
value: 'Hit3',
children: [
{ value: 'Miss11' },
{ value: 'Miss12', children: [{ value: 'Miss13' }] },
],
},
{
value: 'Miss14',
children: [
{ value: 'Hit4' },
{ value: 'Miss15', children: [{ value: 'Miss16' }] },
],
},
];
var keyword = 'Hit';
// We will need 2 passes, first - to collect needed nodes with 'Hit' value:
var foundHit = _.filterDeep(
input,
function(value, key, path, depth, parent, parentKey, parentPath) {
expect(path).to.be.an.array();
expect(parentPath).to.be.an.array();
if (value.value && value.value.includes(keyword)) return true;
},
{
condense: false, // keep empty slots in array to preserve correct paths
leafsOnly: false,
pathFormat: 'array',
}
);
// second pass - to add missed fields both for found 'Hit' nodes and their parents.
var filtrate = _.filterDeep(
input,
function(value, key, path, depth, parent, parentKey, parentPath) {
expect(path).to.be.an.array();
expect(parentPath).to.be.an.array();
if (
_.get(foundHit, path) !== undefined ||
_.get(foundHit, parentPath) !== undefined
) {
return true;
}
},
{
pathFormat: 'array',
}
);
expect(filtrate).to.deep.equal([
{
value: 'Miss1',
children: [{ value: 'Hit1', children: [{ value: 'Miss3' }] }],
},
{
value: 'Miss4',
children: [{ value: 'Miss6', children: [{ value: 'Hit2' }] }],
},
{
value: 'Hit3',
children: [
{ value: 'Miss11' },
{ value: 'Miss12', children: [{ value: 'Miss13' }] },
],
},
{
value: 'Miss14',
children: [{ value: 'Hit4' }],
},
]);
});
});
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