Package Exports
- lodash-deep
This package does not declare an exports field, so the exports above have been automatically detected and optimized by JSPM instead. If any package subpath is missing, it is recommended to post an issue to the original package (lodash-deep) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.
Readme
lodash-deep
Lodash mixins for (deep) object accessing / manipulation.
Installation
Bower
bower install lodash-deep- Reference
lodash-deep.min.jsafterlodash.min.js
Node.js
npm install lodashnpm install lodash-deepvar _ = require("lodash"); _.mixin(require("lodash-deep"));
Docs
The following mixins are included in lodash-deep:
_.deepSet(object, propertyPath, value)
Sets a value of a property in an object tree. Any missing objects will be created.
object
Type: Object
The root object of the object tree.
propertyPath
Type: string
The dot separated propertyPath.
value
Type: *
The value to set.
returns
Type: Object
var object = {};
_.deepSet(object, 'level1.level2.level3.value', 'value 3');
// -> { level1: { level2: { level3: { value: 'value 3' }}}}
_.deepSet(object, 'level1.level2.level3.value', 'foo');
// -> { level1: { level2: { level3: { value: 'foo' }}}}_.deepGet(object, propertyPath)
Retreives the value of a property in an object tree.
object
Type: Object
The root object of the object tree.
propertyPath
Type: string
The dot separated propertyPath.
returns
Type: *|undefined
The value, or undefined if it doesn't exists.
var object = {
level1: {
value: 'value 1',
level2: Object.create({
level3: {
value: 'value 3'
}
})
}
};
_.deepGet(object, 'level1.value');
// -> 'value 1'
_.deepGet(object, 'level1.level2.level3.value');
// -> 'value 3'
_.deepGet(object, 'foo.bar.baz');
// -> undefined_.deepOwn(object, propertyPath)
Retreives the value of a own property in an object tree.
object
Type: Object
The root object of the object tree.
propertyPath
Type: string
The dot separated propertyPath.
returns
Type: *|undefined
The value, or undefined if it doesn't exists.
var object = {
level1: {
value: 'value 1',
level2: Object.create({
level3: {
value: 'value 3'
}
})
}
};
_.deepOwn(object, 'level1.value');
// -> 'value 1'
_.deepOwn(object, 'level1.level2.level3.value');
// -> undefined
_.deepOwn(object, 'foo.bar.baz');
// -> undefined_.deepPluck(collection, propertyPath)
Executes a deep pluck on an collection of object trees.
collection
Type: Object|Array
The collection of object trees.
propertyPath
Type: string
The dot separated propertyPath.
returns
Type: Array
var collection = [
{ level1: { level2: { level3: { value: 1 }}}},
{ level1: { level2: { level3: { value: 2 }}}},
{ level1: { level2: { level3: { value: 3 }}}},
{ level1: { level2: { level3: { value: 4 }}}},
{ level1: { level2: {} }},
{}
];
_.deepPluck(collection, 'level1.level2.level3.value');
// -> [ 1, 2, 3, 4, undefined, undefined ]_.deepIn(object, propertyPath)
Executes a deep check for the existence of a property in an object tree.
object
Type: Object
The root object of the object tree.
propertyPath
Type: string
The dot separated propertyPath.
returns
Type: boolean
var object = {
level1: {
level2: Object.create({
level3: {
value: 'value 3'
}
})
}
};
_.deepIn(object, 'level1');
// -> true
_.deepIn(object, 'level1.level2');
// -> true
_.deepIn(object, 'level1.level2.level3');
// -> true
_.deepIn(object, 'level1.level2.level3.value');
// -> true_.deepHas(object, propertyPath)
Executes a deep check for the existence of a own property in an object tree.
object
Type: Object
The root object of the object tree.
propertyPath
Type: string
The dot separated propertyPath.
returns
Type: boolean
var object = {
level1: {
level2: Object.create({
level3: {
value: 'value 3'
}
})
}
};
_.deepHas(object, 'level1');
// -> true
_.deepHas(object, 'level1.level2');
// -> true
_.deepHas(object, 'level1.level2.level3');
// -> false
_.deepHas(object, 'level1.level2.level3.value');
// -> falseFunction name change
In version 1.2.0 function names were simplified. Backward compatibility with the old names remains in place.