@szilanor/stream
    Preparing search index...

    Function partition

    • Returns a collector that partitions the source into two arrays based on a predicate.

      Type Parameters

      • T

        Type of items in the source.

      Parameters

      • predicate: PredicateFunction<T>

        Predicate function to determine which array an element should be added to.

      Returns CollectorFunction<T, [T[], T[]]>

      Collector that partitions the source into two arrays based on a predicate.

      const result = partition<number>((x) => x > 1)([1, 2, 3]);
      console.log(result); // [[2, 3], [1]]