Function
| Static Public Summary | ||
| public |
accessDeep(path: array, obj: object): null | any Safely access deeply nested values in an object. |
|
| public |
arrayChunks(arr: array, len: number): array Group an array's values into subgroups. |
|
| public |
Quickly call a function or fail gracefully if it does not exist. |
|
| public |
The mapObj() method creates a new array with the results of calling a provided function on every element in the calling object. |
|
| public |
Deeply nest and set a value in an object. |
|
Static Public
public accessDeep(path: array, obj: object): null | any source
import {accessDeep} from 'project-helpers/js/object-helpers.js'Safely access deeply nested values in an object. If the path to the value is not valid, the method will gracefully return null.
Params:
| Name | Type | Attribute | Description |
| path | array | the array representation of the path to access. |
|
| obj | object | the object who's value you are trying to access. |
Return:
| null | any | will return null on path not found, or the value found. |
public arrayChunks(arr: array, len: number): array source
import {arrayChunks} from 'project-helpers/js/object-helpers.js'Group an array's values into subgroups.
Params:
| Name | Type | Attribute | Description |
| arr | array | The target array. |
|
| len | number | The length of the chunks. |
Return:
| array | A two-dimensional segmented array. |
public ifFunc(func: function, args: args): any source
import {ifFunc} from 'project-helpers/js/object-helpers.js'Quickly call a function or fail gracefully if it does not exist.
Params:
| Name | Type | Attribute | Description |
| func | function | The function to try to call. |
|
| args | args | The would-be arguments of the function. |
Return:
| any | returns whatever the function returns. |
public mapObj(obj: object, callback: function): array source
import {mapObj} from 'project-helpers/js/object-helpers.js'The mapObj() method creates a new array with the results of calling a provided function on every element in the calling object.
Return:
| array | returns an array with the values of each returned value in the callback. |
public setDeep(obj: object, path: array | string , value: any, setRecursively: boolean): object source
import {setDeep} from 'project-helpers/js/object-helpers.js'Deeply nest and set a value in an object.
Reference
Source
