effect-io-ai

Package: effect
Module: Array

Array.insertAt

Insert an element at the specified index, creating a new NonEmptyArray, or return None if the index is out of bounds.

Example

import { Array } from "effect"

const result = Array.insertAt(['a', 'b', 'c', 'e'], 3, 'd')
console.log(result) // Option.some(['a', 'b', 'c', 'd', 'e'])

Signature

declare const insertAt: { <B>(i: number, b: B): <A>(self: Iterable<A>) => Option.Option<NonEmptyArray<A | B>>; <A, B>(self: Iterable<A>, i: number, b: B): Option.Option<NonEmptyArray<A | B>>; }

Source

Since v2.0.0