effect-io-ai

Package: effect
Module: Array

Array.splitAtNonEmpty

Splits a non-empty array into two parts at the given index. The first part is guaranteed to be non-empty (n is clamped to >= 1).

When to use

Use when downstream code requires the left side of the split to contain at least one element.

Example (Splitting a non-empty array)

import { Array } from "effect"

console.log(Array.splitAtNonEmpty(["a", "b", "c", "d", "e"], 3))
// [["a", "b", "c"], ["d", "e"]]

See

Signature

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

Source

Since v4.0.0