Function partitionArray

  • Split an array into two subarrays using a predicate function

    Returns

    the two partitions

    Example

    const [even, odd] = partitionArray([1, 2, 3, 4], x => x % 2 === 0)
    even === [2, 4]
    odd === [1, 3]

    Type Parameters

    • T

    Parameters

    • array: T[]

      the array to partition

    • predicateFn: ((t) => boolean)

      the boolean predicate to split along

        • (t): boolean
        • Parameters

          • t: T

          Returns boolean

    Returns [T[], T[]]

Generated using TypeDoc