effect-io-ai

Package: effect
Module: Array

Array.fromIterable

Converts an Iterable to an Array.

When to use

Use to convert any Iterable (Set, Generator, etc.) into an array.

Details

If the input is already an array, this returns it by reference without copying. Otherwise, it creates a new array from the iterable. Use copy if you need a fresh array even when the input is already an array.

Example (Converting a Set to an array)

import { Array } from "effect"

const result = Array.fromIterable(new Set([1, 2, 3]))
console.log(result) // [1, 2, 3]

See

Signature

declare const fromIterable: <A>(collection: Iterable<A>) => Array<A>

Source

Since v2.0.0