Skip to main content

type filter

Returns an async transformer that filters elements from the input stream based on the provided predicate function.

note

if the predicate is a type guard, the return type is automatically inferred

Definition

filter: {
    <T, TF extends T>(pred: (value: T, index: number, halt: () => void) => value is TF, options?: {
      negate?: false | undefined;
    }): AsyncTransformer<TF>;
    <T, TF extends T>(pred: (value: T, index: number, halt: () => void) => value is TF, options: {
      negate: true;
    }): AsyncTransformer<Exclude<T, TF>>;
    <T>(pred: (value: T, index: number, halt: () => void) => MaybePromise<boolean>, options?: {
      negate?: boolean | undefined;
    }): AsyncTransformer<T>;
  }