DEV Community ๐Ÿ‘ฉโ€๐Ÿ’ป๐Ÿ‘จโ€๐Ÿ’ป

DEV Community ๐Ÿ‘ฉโ€๐Ÿ’ป๐Ÿ‘จโ€๐Ÿ’ป is a community of 963,864 amazing developers

We're a place where coders share, stay up-to-date and grow their careers.

Create account Log in
Lรขm
Lรขm

Posted on

101 Cheat Sheet

Reference

isFloat = passAll(isNumber, compose(isInteger, not))
// n => isNumber(n) && not(isInteger(n))
Enter fullscreen mode Exit fullscreen mode
function doStuff (object, options) { ... }

doStuffForce = curry(flip(doStuff))({ force: true })
Enter fullscreen mode Exit fullscreen mode

[Arrays] Grouping

groupBy(list, 'id')
indexBy(list, 'id')
Enter fullscreen mode Exit fullscreen mode

[Arrays] Finding

find(list, x => x.y === 2)
findIndex(list, x => ...)
includes(list, 'item')
last(list)
Enter fullscreen mode Exit fullscreen mode
find(list, hasProps('id'))
Enter fullscreen mode Exit fullscreen mode

[Functions] Converge

converge(and, [pluck('a'), pluck('b')])(x)
Enter fullscreen mode Exit fullscreen mode
// โ†’ and(pluck(x, 'a'), pluck(x, 'b'))
Enter fullscreen mode Exit fullscreen mode

See:
converge

[Functions] And/or

passAll(f, g)       // x => f(x) && g(x)
passAny(f, g)       // x => f(x) || g(x)
Enter fullscreen mode Exit fullscreen mode

See:
passAll,
passAny

[Functions] Composition

compose(f, g)       // x => f(g(x))
curry(f)            // x => y => f(x, y)
flip(f)             // f(x, y) --> f(y, x)
Enter fullscreen mode Exit fullscreen mode

See:
compose,
curry,
flip

[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.

See:
and,
equals,
exists

[Objects] Get values

values(state)
Enter fullscreen mode Exit fullscreen mode

[Objects] Keypath check

hasKeypaths(state, ['user'])
hasKeypaths(state, { 'user.profile.name': 'john' })
Enter fullscreen mode Exit fullscreen mode

See:
hasKeypaths

Reference

Top comments (0)

๐ŸŒš Browsing with dark mode makes you a better developer by a factor of exactly 40.

It's a scientific fact.