Package: effect
Module: Array
Splits an iterable at the first element matching the predicate. The matching element is included in the second array.
When to use
Use when you need to split an array at the first element that marks a condition boundary.
Example (Splitting at a condition)
import { Array } from "effect"
console.log(Array.splitWhere([1, 2, 3, 4, 5], (n) => n > 3)) // [[1, 2, 3], [4, 5]]
See
span — splits at the first element that fails the predicatesplitAt — split at a fixed indexSignature
declare const splitWhere: { <A>(predicate: (a: NoInfer<A>, i: number) => boolean): (self: Iterable<A>) => [beforeMatch: Array<A>, fromMatch: Array<A>]; <A>(self: Iterable<A>, predicate: (a: A, i: number) => boolean): [beforeMatch: Array<A>, fromMatch: Array<A>]; }
Since v2.0.0