Function findAllIndices

  • Returns an array of all indices of an array that pass condition.

    Example

    import * as A from "flurp/array";
    import * as N from "flurp/number";

    const indicesOfPositive = A.findAllIndices(N.isPositive);
    indicesOfPositive([3, -4, -1, 5, -4, 2]); // [0, 3, 5]
    indicesOfPositive([-3, -4, -1, -5, -4, -2]); // []

    Type Parameters

    • T

    Parameters

    • condition: ((x: T) => boolean)
        • (x: T): boolean
        • Parameters

          • x: T

          Returns boolean

    Returns ((arr: readonly T[]) => number[])

      • (arr: readonly T[]): number[]
      • Parameters

        • arr: readonly T[]

        Returns number[]