Function reduceWhile

  • 🦴 utilities

    reduce() with predicate for early termination. A simple version of the same function in the ramda package.

    Type Parameters

    • T
    • R

    Parameters

    • predicate: ((acc: R, currentValue: T) => boolean)
        • (acc, currentValue): boolean
        • Parameters

          • acc: R
          • currentValue: T

          Returns boolean

    • callbackfn: ((previousValue: R, currentValue: T, currentIndex: number, array: T[]) => R)
        • (previousValue, currentValue, currentIndex, array): R
        • Parameters

          • previousValue: R
          • currentValue: T
          • currentIndex: number
          • array: T[]

          Returns R

    • initialValue: R
    • array: T[]

    Returns R