lodash-deep
Lodash mixins for (deep) object accessing / manipulation.!Bower versionbower-imagebower-url !NPM versionnpm-imagenpm-url !Build Statustravis-imagetravis-url !Sauce Test Statussauce-imagesauce-url !Dependency Statusdepstat-imagedepstat-url
Version 2.x
In 2.0 most of the methods of this module where removed, because Lodash now supports their functionality natively. E.g.: ``` javascript .deepGet(object, 'father.name'); // -> .get(object, 'father.name'); .deepPluck(array, 'father.name'); // -> .map(array, 'father.name'); ```Compatibility
lodash-deep is currently compatible with:- Node.js
- All ES5 compatible browsers (IE9+, Chrome, Firefox, Safari etc)
Installation
Bower
bower install lodash-deep
- Reference
lodash-deep.min.js
afterlodash.min.js
Node.js
npm install lodash
npm install lodash-deep
``` javascript
var _ = require("lodash");
_.mixin(require("lodash-deep"));
```
Docs
The following mixins are included inlodash-deep
:
.deepMapValues(object, propertyPath)
Maps all values in an object tree and returns a new object with the same structure as the original.object
Type:Object
The root object of the object tree.
callback
Type:Function
The function to be called per iteration on any non-object value in the tree.
Callback is invoked with 2 arguments: (value, path)
.
value
the value of the current property.
path
the path of the current property.
returns
Type:Object
``` javascript
var object = {
level1: {
value: 'value 1'
level2: {
value: 'value 2'
level3: {
value: 'value 3'
}
}
}
};
.deepMapValues(object, function(value, path){
return path + ' is ' + value)
});
/ ->
{
level1: {
value: 'level1.value is value 1'
level2: {
value: 'level1.level2.value is value 2'
level3: {
value: 'level1.level2.level3.value is value 3'
}
}
}
};
/
```
Contributing
Please use thecanary
branch when creating a pull request.