effect-io-ai

Package: effect
Module: Array

Array.splitAt

Splits an Iterable into two segments, with the first segment containing a maximum of n elements. The value of n can be 0.

Example

import { Array } from "effect"

const result = Array.splitAt([1, 2, 3, 4, 5], 3)
console.log(result) // [[1, 2, 3], [4, 5]]

Signature

declare const splitAt: { (n: number): <A>(self: Iterable<A>) => [beforeIndex: Array<A>, fromIndex: Array<A>]; <A>(self: Iterable<A>, n: number): [beforeIndex: Array<A>, fromIndex: Array<A>]; }

Source

Since v2.0.0