Composite utilities (immutability, fp helpers)
NOTE: All the functions described in API are curried
- Installation
- Types
- API
- License
Using npm
$ npm install --save @jumpn/utils-composite
Using yarn
$ yarn add @jumpn/utils-composite
type Composite = Array<*> | Object;
type Key = number | string;
type Path = Array<Key>;
Get property value of given key.
keyKeycompositeComposite
Returns any
Returns value located at the given path or undefined otherwise.
pathPathcompositeComposite
Returns any
Get own enumerable keys.
compositeComposite
Returns Array<Key>
Returns true if value located at given path is deeply equal to the one specified.
pathPathvalueanycompositeComposite
Returns boolean
Returns true if key is included in composite's own enumerable ones, or false otherwise.
keyKeycompositeComposite
Returns boolean
Returns true if both composites have the same props or false otherwise.
c1Compositec2Composite
Returns boolean
Returns true if parameter is a Composite or false otherwise
thingany
Returns true if composite has no own enumerable keys (is empty) or false otherwise
compositeComposite
Returns boolean
Maps values of the given composite using mapper
mapperfunction (value: any, key: Key, composite: $Supertype<C>): anycompositeC
Returns $Supertype<C>
Returns a new composite with the result of having removed the property with the given key.
keyKeycompositeComposite
Returns Composite
Returns a new composite with the result of having removed the property located at the given path.
(This does the same as calling updateIn with updater:
() => updateIn.remove)
pathPathcompositeComposite
Returns Composite
Returns a new composite with the result of having updated the property with the given key with the specified value.
keyKeyvalueanycompositeComposite
Returns Composite
Returns a new composite with the result of having updated the property located at the given path with the specified value.
(This does the same as calling updateIn with updater: () => value)
pathPathvalueanycompositeComposite
Returns Composite
Returns a new composite with the same own enumerable props of the one given.
compositeC
Returns C
Returns true if both composites are of the same type (Array or Object) and their properties are strictly equal.
c1Compositec2Composite
Returns boolean
Returns given composite if it has any own enumerable keys (is not empty) or undefined otherwise
compositeComposite
Returns Composite
Returns a new composite with the result of having updated the property value at the given path with the result of the call to updater function.
Entry removal is supported by returning updateIn.remove symbol on updater
function.
pathPathupdaterfunction (prev: any): anycompositeComposite
Returns Composite
MIT ©️ Jumpn Limited / Mauro Titimoli ([email protected])