import { AsyncReducer } from "https://deno.land/x/rimbu@1.2.1/stream/async/async-reducer.ts";
const { partition } = AsyncReducer;
Returns an AsyncReducer
that splits the incoming values into two separate outputs based on the given pred
predicate. Values for which the predicate is true
are fed into the collectorTrue
reducer, and other values are fed into the collectorFalse
instance. If no collectors are provided the values are collected
into arrays.
type
{ <T, T2 extends T, RT, RF = RT>(pred: (value: T, index: number) => value is T2, options: { collectorTrue: AsyncReducer.Accept<T2, RT>; collectorFalse: AsyncReducer.Accept<Exclude<T, T2>, RF>; }): AsyncReducer<T, [RT, RF]>; <T, T2 extends T>(pred: (value: T, index: number) => value is T2, options?: { collectorTrue?: undefined; collectorFalse?: undefined; }): AsyncReducer<T, [T2[], Exclude<T, T2>[]]>; <T, RT, RF = RT>(pred: (value: T, index: number) => MaybePromise<boolean>, options: { collectorTrue: AsyncReducer.Accept<T, RT>; collectorFalse: AsyncReducer.Accept<T, RF>; }): AsyncReducer<T, [RT, RF]>; <T>(pred: (value: T, index: number) => MaybePromise<boolean>, options?: { collectorTrue?: undefined; collectorFalse?: undefined; }): AsyncReducer<T, [T[], T[]]>; }