@eroyeroy/utils - v0.1.0
    Preparing search index...

    Function partitionArray

    • Splits an array into two groups: items matching predicate and items that do not. Returns [matched, unmatched].

      Type Parameters

      • T

      Parameters

      • array: readonly T[]

        The source array.

      • predicate: (item: T, index: number, array: readonly T[]) => boolean

        Function to test each item.

      Returns [matched: T[], unmatched: T[]]

      partitionArray([1, 2, 3, 4, 5], n => n % 2 === 0)
      // => [[2, 4], [1, 3, 5]]