Skip to content

atOrThrow

Array.atOrThrow(array, offset)

Returns the value at the specified offset, throws an exception if the offset was out of range, or the retrieved value was nullable.

Example

ts
import { Array } from "@monstermann/array";

Array.atOrThrow([1, null], -1); // Error
ts
import { Array } from "@monstermann/array";

pipe([1, null], Array.atOrThrow(-1)); // Error