parameter-reduction
Tired of defining parameter for resolvers? This might be your friend.
FEATURING
Calling array methods
- array methods
- map
- filter
- sort
- reduce
- reduceRight
- forEach
- join
- concat
- optional methods
- map
- filter
- forEach
- concat
Optional
wraps single values and enables you to handle them like arrays.
const wrap map filter unwrap = num + increment num % 2; Promise //now, concerns are separated. ;
Utility methods
flatten
flattens array of arrays to array (reduces 1 dimension)
const flatten = ;; //returns [1, 2, 3, 4, 5, 6, 7, 8, 9]
sift
sift elements with multiple criterias. Plus, you can get the rests.
const sift = ;;/* * returns * [ * [6, 7, 8, 9, 10], * [], * [2, 4], * [5], * [1, 3] // rests * ] */
siftBy
callback-friendly implement of sift, you can give criterias first.
const siftBy = ;Promise;/* * resolves * [ * [6, 7, 8, 9, 10], * [], * [2, 4], * [5], * [1, 3] * ] */
head, tail, last, init
returns
- head: the first element or undefined
- tail: array of elements other than the first one or []
- last: the last element or undefined
- init: array of elements other than the last one or []
EXAMPLE
You can make this
const add = num + increment num % 2 soFar + current; Promise ;
Like this!
const map filter reduce = num + increment num % 2 soFar + current; Promise ;