Methods
(static) concat(src, key, val) → {Object}
immutable! return copied object where set property value in object by path
.immutable! return copied object where set property value in object by path
Parameters:
Name | Type | Description |
---|---|---|
src |
Object | source object |
key |
String | path |
val |
Any | value |
Returns:
copy of modified source object
- Type
- Object
(static) get(obj, path, defValue) → {Any}
get prop by path
.get prop by path
Parameters:
Name | Type | Description |
---|---|---|
obj |
Object | source object |
path |
String | Array | path, for example 'a.b.c.d' |
defValue |
String | default value |
Returns:
property by path
- Type
- Any
Example
obj = {a: {b: {c: {d: 42}}}}, get(obj, 'a.b.c.d') will return 42
(static) reassemble(obj, paths) → {Object}
return reassembled object with keys when key can be reassigned from any source level to any destination level
.return reassembled object with keys when key can be reassigned from any source level to any destination level
Parameters:
Name | Type | Description |
---|---|---|
obj |
Object | source object |
paths |
Array | path, for reassign prop path must be in format 'oldPropPath->newPropPath' |
Returns:
- Type
- Object
Example
src = {a: {b: {c: {d: 42}}}}, obj(src, ['a.b->b','a.b.c->c']) will return {b: {c: {d: 42}}, c: {d: 42}}
(static) set(src, key, val) → {Object}
set property value in object by path
.set property value in object by path
Parameters:
Name | Type | Description |
---|---|---|
src |
Object | source object |
key |
String | path |
val |
Any | value |
Returns:
modified source object
- Type
- Object