Reference
- https://github.com/tjmehta/101 ### [Examples] Function composition
isFloat = passAll(isNumber, compose(isInteger, not))
// n => isNumber(n) && not(isInteger(n))
function doStuff (object, options) { ... }
doStuffForce = curry(flip(doStuff))({ force: true })
[Arrays] Grouping
groupBy(list, 'id')
indexBy(list, 'id')
[Arrays] Finding
find(list, x => x.y === 2)
findIndex(list, x => ...)
includes(list, 'item')
last(list)
find(list, hasProps('id'))
[Functions] Converge
converge(and, [pluck('a'), pluck('b')])(x)
// → and(pluck(x, 'a'), pluck(x, 'b'))
See:
converge
[Functions] And/or
passAll(f, g) // x => f(x) && g(x)
passAny(f, g) // x => f(x) || g(x)
[Functions] Composition
compose(f, g) // x => f(g(x))
curry(f) // x => y => f(x, y)
flip(f) // f(x, y) --> f(y, x)
[Functions] Simple functions
| and(x, y)
| x && y
|
| or(x, y)
| x || y
|
| xor(x, y)
| !(!x && !y) && !(x && y)
|
| equals(x, y)
| x === y
|
| exists(x)
| !!x
|
| not(x)
| !x
|
Useful for function composition.
[Objects] Get values
values(state)
[Objects] Keypath check
hasKeypaths(state, ['user'])
hasKeypaths(state, { 'user.profile.name': 'john' })
See:
hasKeypaths
Top comments (0)