UNPKG

tamda

Version:

Practical functional programming library for TypeScript

17 lines 583 B
import { infer } from '../function/infer'; export function reduceWhile() { return inferred.apply(undefined, arguments); } const inferred = infer((array, whileFn, reduceFn, initialValue) => { let accumulator = initialValue; for (let index = 0; index < array.length; index++) { const item = array[index]; const next = reduceFn(accumulator, item, index, array); if (!whileFn(next, item, index, array)) { break; } accumulator = next; } return accumulator; }); //# sourceMappingURL=reduceWhile.js.map