Comparing version 1.3.2 to 1.4.0
@@ -92,2 +92,3 @@ 'use strict'; | ||
includeCircularPath: true, | ||
leafsOnly:false | ||
}, | ||
@@ -117,2 +118,5 @@ options || {} | ||
if(!circular||options.includeCircularPath){ | ||
if(options.leafsOnly && _.last(res)===parentPath){ | ||
res.pop(); | ||
} | ||
res.push(path); | ||
@@ -119,0 +123,0 @@ } |
{ | ||
"name": "deepdash", | ||
"version": "1.3.2", | ||
"version": "1.4.0", | ||
"description": "Object tree traversal for lodash", | ||
@@ -21,4 +21,2 @@ "main": "deepdash.js", | ||
"object", | ||
"traversal", | ||
"lodash", | ||
"tree", | ||
@@ -25,0 +23,0 @@ "traversal", |
@@ -150,3 +150,4 @@ <img src="deepdash.svg?sanitize=true" width="64px"/> | ||
- \[checkCircular\]: (Boolean) option (false by default) to avoid circular references. | ||
- \[includeCircularPath\]: (Boolean) option (true by default) return path to circular reference, if found some, or not. | ||
- \[includeCircularPath\]: (Boolean) option (true by default) return path to circular reference, if found some, or skip it. | ||
- \[leafsOnly\]: (Boolean) option (false by default) return paths to childless values only. | ||
@@ -153,0 +154,0 @@ **Example:** |
@@ -20,10 +20,13 @@ 'use strict'; | ||
it('Array', () => { | ||
let keys = _.keysDeep([demo,demo]); | ||
let keys = _.keysDeep([demo, demo]); | ||
expect(keys.length).equal(62); | ||
}); | ||
it('Count paths circular', () => { | ||
let keys = _.keysDeep(circular,{checkCircular:true}); | ||
let keys = _.keysDeep(circular, { checkCircular: true }); | ||
// console.log(keys); | ||
expect(keys.length).equal(23); | ||
keys = _.keysDeep(circular,{checkCircular:true,includeCircularPath:false}); | ||
keys = _.keysDeep(circular, { | ||
checkCircular: true, | ||
includeCircularPath: false, | ||
}); | ||
// console.log(keys); | ||
@@ -44,16 +47,54 @@ expect(keys.length).equal(20); | ||
let keys = _.keysDeep(1); | ||
expect(keys).to.be.array().and.has.property('length').equal(0); | ||
expect(keys) | ||
.to.be.array() | ||
.and.has.property('length') | ||
.equal(0); | ||
keys = _.keysDeep('123'); | ||
expect(keys).to.be.array().and.has.property('length').equal(0); | ||
expect(keys) | ||
.to.be.array() | ||
.and.has.property('length') | ||
.equal(0); | ||
keys = _.keysDeep(null); | ||
expect(keys).to.be.array().and.has.property('length').equal(0); | ||
expect(keys) | ||
.to.be.array() | ||
.and.has.property('length') | ||
.equal(0); | ||
keys = _.keysDeep(undefined); | ||
expect(keys).to.be.array().and.has.property('length').equal(0); | ||
keys = _.keysDeep(()=>{}); | ||
expect(keys).to.be.array().and.has.property('length').equal(0); | ||
expect(keys) | ||
.to.be.array() | ||
.and.has.property('length') | ||
.equal(0); | ||
keys = _.keysDeep(() => {}); | ||
expect(keys) | ||
.to.be.array() | ||
.and.has.property('length') | ||
.equal(0); | ||
keys = _.keysDeep(new Date()); | ||
expect(keys).to.be.array().and.has.property('length').equal(0); | ||
expect(keys) | ||
.to.be.array() | ||
.and.has.property('length') | ||
.equal(0); | ||
keys = _.keysDeep(/.*/); | ||
expect(keys).to.be.array().and.has.property('length').equal(0); | ||
expect(keys) | ||
.to.be.array() | ||
.and.has.property('length') | ||
.equal(0); | ||
}); | ||
it('Leafs only', () => { | ||
let keys = _.keysDeep(demo, { leafsOnly: true }); | ||
expect(keys.length).equal(14); | ||
}); | ||
it('Leafs only circular', () => { | ||
let keys = _.keysDeep(circular, { checkCircular: true, leafsOnly: true }); | ||
expect(keys.length).equal(10); | ||
keys = _.keysDeep(circular, { | ||
checkCircular: true, | ||
includeCircularPath: false, | ||
leafsOnly: true | ||
}); | ||
expect(keys.length).equal(9); | ||
}); | ||
}); |
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
25291
13
572
178