Hi there! Are you looking for the official Deno documentation? Try docs.deno.com for all your Deno learning needs.

collect

import { collect } from "https://github.gh-proxy.cn/raw.githubusercontent.com/baetheus/fun/main/iterable.ts";

Collect all values of an Iterable into an array.

⚠️ Warning: If the Iterable is infinite, this will cause the program to hang indefinitely.

@example
import * as I from "./iterable.ts";

const numbers = I.wrap(1, 2, 3, 4, 5);
const array = I.collect(numbers); // [1, 2, 3, 4, 5]

// Be careful with infinite iterables!
// const infinite = I.range(); // Infinite range
// const result = I.collect(infinite); // This will hang!
function collect<A>(ta: Iterable<A>): ReadonlyArray<A>;
§
collect<A>(ta: Iterable<A>): ReadonlyArray<A>
[src]

§Type Parameters

§Parameters

§
ta: Iterable<A>
[src]

§Return Type

§
ReadonlyArray<A>
[src]