<A>(collection: Iterable<A>): Array<A>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]export const const fromIterable: <A>(
collection: Iterable<A>
) => Array<A>
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]
fromIterable = <function (type parameter) A in <A>(collection: Iterable<A>): Array<A>A>(collection: Iterable<A>collection: interface Iterable<T, TReturn = any, TNext = any>Iterable<function (type parameter) A in <A>(collection: Iterable<A>): Array<A>A>): interface Array<T>Array<function (type parameter) A in <A>(collection: Iterable<A>): Array<A>A> =>
const Array: ArrayConstructorExposes the global array constructor.
When to use
Use to access native JavaScript array constructor methods such as isArray
or from from the Effect module namespace.
Example (Accessing the Array constructor)
import { Array } from "effect"
const arr = new Array.Array(3)
console.log(arr) // [undefined, undefined, undefined]
Array.ArrayConstructor.isArray(arg: any): arg is any[]isArray(collection: Iterable<A>collection) ? collection: any[]collection : const Array: ArrayConstructorExposes the global array constructor.
When to use
Use to access native JavaScript array constructor methods such as isArray
or from from the Effect module namespace.
Example (Accessing the Array constructor)
import { Array } from "effect"
const arr = new Array.Array(3)
console.log(arr) // [undefined, undefined, undefined]
Array.ArrayConstructor.from<A>(iterable: Iterable<A> | ArrayLike<A>): A[] (+3 overloads)Creates an array from an iterable object.
from(collection: Iterable<A>collection)