Usage
const isObject = require('101/isObject')
isObject({}) // → true
Every function is exposed as a module.
See: 101
Type checking
isObject({})
isString('str')
isRegExp(/regexp/)
isBoolean(true)
isEmpty({})
isfunction(x => x)
isInteger(10)
isNumber(10.1)
instanceOf(obj, 'string')
Objects
Example
let obj = {}
Update
obj = put(obj, 'user.name', 'John')
// → { user: { name: 'John' } }
Read
pluck(name, 'user.name')
// → 'John'
Delete
obj = del(obj, 'user')
// → { }
Getting
Setting
put(state, 'user.profile.name', 'john')
See: put
Deleting
Keypath check
hasKeypaths(state, ['user'])
hasKeypaths(state, { 'user.profile.name': 'john' })
See: hasKeypaths
Get values
values(state)
Functions
Simple functions
Composition
And/or
Converge
Arrays
Finding
find(list, x => x.y === 2)
findIndex(list, x => ...)
includes(list, 'item')
last(list)
find(list, hasProps('id'))
Grouping
groupBy(list, 'id')
indexBy(list, 'id')
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 })
0 Comments for this cheatsheet. Write yours!