Comparing version 1.6.2 to 1.6.3
{ | ||
"name": "deepdash", | ||
"version": "1.6.2", | ||
"version": "1.6.3", | ||
"description": "Object tree traversal for lodash", | ||
@@ -5,0 +5,0 @@ "main": "deepdash.js", |
@@ -148,2 +148,106 @@ 'use strict'; | ||
}); | ||
//https://stackoverflow.com/questions/48270845/deep-filtering-array-of-objects-javascript | ||
it('deep-filtering-array-of-objects-javascript', function() { | ||
var types = [ | ||
{ | ||
name: 'Dresses', | ||
checked: true, | ||
collections: [ | ||
{ | ||
name: 'My Collection', | ||
checked: true, | ||
variations: [ | ||
{ | ||
size: 'XXS', | ||
checked: true, | ||
}, | ||
{ | ||
size: 'XS', | ||
checked: false, | ||
}, | ||
], | ||
}, | ||
{ | ||
name: 'False Collection', | ||
checked: false, | ||
variations: [ | ||
{ | ||
size: 'XXS', | ||
checked: false, | ||
}, | ||
{ | ||
size: 'XS', | ||
checked: false, | ||
}, | ||
], | ||
}, | ||
], | ||
}, | ||
{ | ||
name: 'Tops', | ||
checked: true, | ||
collections: [ | ||
{ | ||
name: 'Another Collection', | ||
checked: true, | ||
variations: [ | ||
{ | ||
size: 'XXS', | ||
checked: false, | ||
}, | ||
{ | ||
size: 'XS', | ||
checked: true, | ||
}, | ||
], | ||
}, | ||
], | ||
}, | ||
]; | ||
var filtrate = _.filterDeep(types, function( | ||
value, | ||
key, | ||
path, | ||
depth, | ||
parent | ||
) { | ||
if (parent.checked) return true; | ||
}); | ||
expect(filtrate).to.deep.equal([ | ||
{ | ||
name: 'Dresses', | ||
checked: true, | ||
collections: [ | ||
{ | ||
name: 'My Collection', | ||
checked: true, | ||
variations: [ | ||
{ | ||
size: 'XXS', | ||
checked: true, | ||
}, | ||
], | ||
}, | ||
], | ||
}, | ||
{ | ||
name: 'Tops', | ||
checked: true, | ||
collections: [ | ||
{ | ||
name: 'Another Collection', | ||
checked: true, | ||
variations: [ | ||
{ | ||
size: 'XS', | ||
checked: true, | ||
}, | ||
], | ||
}, | ||
], | ||
}, | ||
]); | ||
}); | ||
}); |
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
58650
1557