Skip to main content
Deno 2 is finally here 🎉️
Learn more
Module

x/rimbu/mod.ts>Transformer.splitWhere

Rimbu is a TypeScript library focused on immutable, performant, and type-safe collections and other tools.
Go to Latest
function Transformer.splitWhere
import { Transformer } from "https://deno.land/x/rimbu@1.2.0/mod.ts";
const { splitWhere } = Transformer;

Returns a Transformer that applies the given pred function to each received element, and collects the received elements into a collector that will be returned as output every time the predicate returns true.

Parameters

pred: (value: T, index: number) => boolean
  • a predicate function taking an element
optional
options: { negate?: boolean | undefined; collector?: Reducer<T, R> | undefined; } = [UNSUPPORTED]
  • (optional) object specifying the following properties
  • negate: (default: false) when true will negate the given predicate
  • collector: (default: Reducer.toArray()) a Reducer that can accept multiple values and reduce them into a single value of type R.