effect-io-ai

Package: effect
Module: Array

Array.reverse

Reverses an iterable into a new array.

When to use

Use to reverse an iterable into a new array without mutating the original input.

Details

Preserves NonEmptyArray in the return type.

Example (Reversing an array)

import { Array } from "effect"

console.log(Array.reverse([1, 2, 3, 4])) // [4, 3, 2, 1]

Signature

declare const reverse: <S extends Iterable<any>>(self: S) => S extends NonEmptyReadonlyArray<infer A> ? NonEmptyArray<A> : S extends Iterable<infer A> ? Array<A> : never

Source

Since v2.0.0