Comparing version 1.0.1 to 1.1.0
@@ -5,5 +5,6 @@ (function(){ | ||
if(!_.eachDeep){ | ||
_.eachDeep = function(obj,callback){ | ||
function eachDeep(obj,callback){ | ||
iterate(obj,"",0,null,"","",callback); | ||
}; | ||
_.mixin({ 'eachDeep': eachDeep }); | ||
} | ||
@@ -10,0 +11,0 @@ function iterate(obj,path,depth,parent,parentKey,parentPath,callback) |
@@ -0,2 +1,6 @@ | ||
//inject new method into lodash object | ||
const _ = require('./deepdash')(require('lodash')); | ||
//in browser just load script after lodash | ||
//<script src="lodash.js"></script> | ||
//<script src="deepdash.js"></script> | ||
let obj = { | ||
@@ -50,1 +54,4 @@ a: { | ||
}); | ||
// Chaining works too | ||
// _(obj).eachDeep((value, key, path, depth, parent, parentKey, parentPath) => {/* do */}).value(); |
{ | ||
"name": "deepdash", | ||
"version": "1.0.1", | ||
"version": "1.1.0", | ||
"description": "Object tree traversal for lodash", | ||
@@ -5,0 +5,0 @@ "main": "deepdash.js", |
@@ -99,4 +99,10 @@ ## deepdash | ||
``` | ||
Chaining works too: | ||
```js | ||
_.eachDeep(obj, (value, key, path, depth, parent, parentKey, parentPath) => { | ||
//do | ||
}).value(); | ||
``` | ||
### Other traversal methods | ||
Feel free to request other methods implementation like `filterDeep`, `mapDeep` and soon. |
@@ -55,2 +55,12 @@ const chai = require('chai'), | ||
}); | ||
it('Chaining',()=>{ | ||
let c = 0; | ||
_(obj).eachDeep( | ||
(value, key, path, depth, parent, parentKey, parentPath) => { | ||
if (key == 'skip') return false; | ||
c++; | ||
} | ||
).value(); | ||
expect(c).equal(25); | ||
}); | ||
}); |
Sorry, the diff of this file is not supported yet
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
9698
168
107