UNPKG

foldable

Version:
12 lines (8 loc) 151 B
function fold (iter, init, fun) { let acc = init for (const value of iter) { acc = fun(acc, value) } return acc } module.exports = fold