Exports deepAssign, deepFreeze, get, has, set, defaults, recurseObjectByPath
- Version:
-
- 3.0.0
- Since:
-
- 1.0.0
- Source:
Methods
-
<static> deepAssign(left, path, right)
-
Recursively calls Object.assign along the specified path.
Parameters:
Name Type Description left
Object left source path
String path to target right
Object right source Returns:
- Type
- Object
Example
let user = { name: 'Alan', account: { active: true, products: { '1': true, '2': true, '3': true } }, preferences: { locale: 'en-US' } }; deepAssign(user, 'account.products', { 2: false }); { // new ref name: 'Alan', account: { // new ref active: true, products: { // new ref '1': true, '2': false, '3': true } }, preferences: { // same ref locale: 'en-US' } };
-
<static> defaults(target, defaultOptions)
-
Assigns missing defaultOptions onto the target object.
Parameters:
Name Type Description target
Object defaultOptions
Object - Source:
Returns:
- Type
- Object
-
<static> exports.deepFreeze(source)
-
Recursively calls Object.freeze on objects properties
Parameters:
Name Type Description source
Object Returns:
- Type
- Object
-
<static> get(obj, path)
-
Returns nested property of an object based on path.
Parameters:
Name Type Description obj
Object path
String dot notation - Source:
-
<static> has(obj, path)
-
Checks if an object has a nested property defined by path.
Parameters:
Name Type Description obj
Object path
String dot notation - Source:
-
<static> recurseObjectByPath(obj, path, op)
-
Abstracts away the recursion function of traversing an object's nested properties by a given path.
Parameters:
Name Type Description obj
Object path
String dot notatino op
function operation to perform as object is recursed by path. - Source:
-
<static> set(obj, path, val)
-
Sets the value of a nested member of an object.
Parameters:
Name Type Description obj
Object path
String val
* - Source: