Function reduceWhile

reduceWhile reduces an iterable until the first None is encountered.

  • Type Parameters

    • T
    • U = T

    Parameters

    • arr: T[]

      An array

    • fn: (
          previousValue: U,
          currentValue: T,
          currentIndex: number,
          array: T[],
      ) => Option<U>

      A function that produces an Option.

    • initialValue: U

      The initial value.

    • OptionalthisArg: any

      If provided, it will be used as the this value for each invocation of predicate. If it is not provided, undefined is used instead.

    Returns U

    The reduced value.