title | category |
---|---|
101 |
JavaScript libraries |
isObject({})
isString('str')
isRegExp(/regexp/)
isBoolean(true)
isEmpty({})
isfunction(x => x)
isInteger(10)
isNumber(10.1)
instanceOf(obj, 'string')
compose(f, g) // x => f(g(x))
curry(f) // x => y => f(x, y)
flip(f) // f(x, y) --> f(y, x)
passAll(f, g) // x => f(x) && g(x)
passAny(f, g) // x => f(x) || g(x)
converge(and, [pluck('a'), pluck('b')])(x)
// and(pluck(x, 'a'), pluck(x, 'b'))
del(state, 'user.profile')
put(state, 'user.profile.name', 'john')
pluck(state, 'user.profile.name')
omit(state, 'user.profile')
pick(state, ['user', 'ui'])
pick(state, /^_/)
hasKeypaths(state, ['user'])
hasKeypaths(state, { 'user.profile.name': 'john' })
values(state)
find(list, x => x.y === 2)
findIndex(list, x => ...)
includes(list, 'item')
last(list)
groupBy(list, 'id')
indexBy(list, 'id')
find(list, hasProps('id'))
Useful for function composition.
and(x, y) // x && y
or(x, y) // x || y
xor(x, y) // !(!x && !y) && !(x && y)
equal(x, y) // x === y
exists(x) // !!x
not(x) // !x
Function composition:
isFloat = passAll(isNumber, compose(isInteger, not))
// n => isNumber(n) && not(isInteger(n))
function doStuff (object, options) { ... }
doStuffForce = curry(flip(doStuff))({ force: true })