core

Members

(static, constant) set

Source:
Since:
  • 1.0.0
Sets the value at path of obj.
Example
set({ nested: { prop: 'old' } }, 'nested.prop', 'new') // => { nested: { prop: 'new' } }

Methods

(static) flow(…args) → {core.flowFunction}

Source:
Since:
  • 1.0.0
Creates a function that will successively call all functions contained in args.
Each function is called with the result of the previous one.
Non functions args are tolerated and will be ignored.
Parameters:
Name Type Attributes Description
args function | Array.<function()>
repeatable
The functions to apply
Returns:
A function successively calling function args
Type
core.flowFunction

(static) get([obj], path) → {*}

Source:
Since:
  • 1.0.0
Gets the value at path of obj.
Example
get({ nested: { prop: 'val' } }, 'nested.prop') // => 'val'
Parameters:
Name Type Attributes Description
obj *
optional
The object.
path string | Array The path of the property to get.
Returns:
Returns the value
Type
*

(static) unset(obj, path) → {Object}

Source:
Since:
  • 1.0.0
Removes the property at path of object.
Example
unset({ nested: { prop: 'value' } }, 'nested.prop') // => { nested: {} }
Parameters:
Name Type Description
obj Object The object to modify.
path Array | string The path of the property to unset.
Returns:
Returns the updated object.
Type
Object

(static) update(obj, path, updater, …args) → {Object}

Source:
Since:
  • 1.0.0
Updates the value at path of object using the updater function.
The updater is invoked with value and …args.
Be carefull, the updater function must not mutate its value argument.
Example

Updating a prop

const inc = (v, i = 1) => v + i // this function increments a number with an optional value which defaults to 1
const object = { nested: { prop: 4 } }
update(object, 'nested.prop', inc) // => { nested: { prop: 5 } }
update(object, 'nested.prop', inc, 2) // => { nested: { prop: 6 } }
Parameters:
Name Type Attributes Description
obj Object The object to modify.
path Array | string The path of the property to set.
updater function The function to produce the updated value.
args *
repeatable
The remaining args.
Returns:
Returns the updated object.
Type
Object

Type Definitions

flowFunction(arg) → {*}

Source:
Since:
  • 1.0.0
A function successively calling a list of functions.
Parameters:
Name Type Description
arg * The starting value
Returns:
The resulting value
Type
*