Composite utilities (immutability, fp helpers)
npm install @jumpn/utils-composite> Composite utilities (immutability, fp helpers)
>
> NOTE: All the functions described in API are curried
- Installation
- Using npm
- Using yarn
- Types
- API
- get
- Parameters
- getIn
- Parameters
- getKeys
- Parameters
- hasIn
- Parameters
- hasKey
- Parameters
- haveSameProps
- Parameters
- is
- Parameters
- isEmpty
- Parameters
- map
- Parameters
- remove
- Parameters
- removeIn
- Parameters
- set
- Parameters
- setIn
- Parameters
- shallowCopy
- Parameters
- shallowEqual
- Parameters
- toUndefinedIfEmpty
- Parameters
- updateIn
- Parameters
- License
$ npm install --save @jumpn/utils-composite
$ yarn add @jumpn/utils-composite
``flowtype
type Composite = Array<*> | Object;
type Key = number | string;
type Path = Array
`
Get property value of given key.
#### Parameters
- key Key composite
- Composite
Returns any
Returns value located at the given path or undefined otherwise.
#### Parameters
- path Path composite
- Composite
Returns any
Get own enumerable keys.
#### Parameters
- composite Composite
Returns Array<Key>
Returns true if value located at given path is deeply equal to the one
specified.
#### Parameters
- path Path value
- any composite
- Composite
Returns boolean
Returns true if key is included in composite's own enumerable ones,
or false otherwise.
#### Parameters
- key Key composite
- Composite
Returns boolean
Returns true if both composites have the same props or false otherwise.
#### Parameters
- c1 Composite c2
- Composite
Returns boolean
Returns true if parameter is a Composite or false otherwise
#### Parameters
- thing any
Returns true if composite has no own enumerable keys (is empty) or false
otherwise
#### Parameters
- composite Composite
Returns boolean
Maps values of the given composite using mapper
#### Parameters
- mapper function (value: any, key: Key, composite: $Supertype<C>): any composite
- C
Returns $Supertype<C>
Returns a new composite with the result of having removed the property with
the given key.
#### Parameters
- key Key composite
- Composite
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)
#### Parameters
- path Path composite
- Composite
Returns Composite
Returns a new composite with the result of having updated the property with
the given key with the specified value.
#### Parameters
- key Key value
- any composite
- Composite
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)
#### Parameters
- path Path value
- any composite
- Composite
Returns Composite
Returns a new composite with the same own enumerable props of the one given.
#### Parameters
- composite C
Returns C
Returns true if both composites are of the same type (Array or Object) and
their properties are strictly equal.
#### Parameters
- c1 Composite c2
- Composite
Returns boolean
Returns given composite if it has any own enumerable keys (is not empty) or
undefined otherwise
#### Parameters
- composite Composite
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.
#### Parameters
- path Path updater
- function (prev: any): any composite` Composite
-
Returns Composite
MIT :copyright: Jumpn Limited / Mauro Titimoli (mauro@jumpn.com)