import { ReduceFunc } from './reduce'; import { CurriedFunction2, CurriedFunction3 } from '../typings/types'; type ReducePred = (acc: R, elem: T, index: number, arr: ArrayLike) => boolean; interface ReduceWhile { (predicate: ReducePred, fn: ReduceFunc, acc: R, list: ArrayLike): R; (predicate: ReducePred, fn: ReduceFunc, acc: R): (list: ArrayLike) => R; (predicate: ReducePred, fn: ReduceFunc): CurriedFunction2, R>; (predicate: ReducePred): CurriedFunction3, R, ArrayLike, R>; } /** * Returns a single item by iterating through the list, successively calling * the iterator function. reduceWhile also takes a predicate that is evaluated * before each step. If the predicate returns false, it "short-circuits" * the iteration and returns the current value of the accumulator. * * **Note:** if `arr` is undefined or null, `acc` will be returned by reference immediately * * @param {Function} pred The predicate function. * If it returns a truthy value, reduce continues. Receives the accumulator and the current element * @param {Function} fn The iterator function. Receives four values, * the accumulator, the current element from the array, its index, and the original array. * @param {*} acc The accumulator value. * @param {Array} arr The list to iterate over. * @return {*} The final, accumulated value. * @example * * reduceWhile(acc => acc.length < 3, (acc, x) => acc + x, '1', ['2', '3', '4', '5']) // '123' * */ declare const _default: ReduceWhile; export default _default;