UNPKG

@wasmuth/reduce

Version:

Practical, functional utilities that fallback on native implementations as much as possible

10 lines (7 loc) 296 B
import check from 'check-arg-types' import partial from '@wasmuth/partial' export default function reduce (fn, initVal, ls) { if (arguments.length < 3) return partial(reduce, arguments) check(arguments, ['function', '-any', 'array']) return Array.prototype.reduce.call(ls, fn, initVal) }