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

clone

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

Create a cloneable version of an Iterable. This caches the results of iteration, allowing the iterable to be consumed multiple times. Note: This can be memory-intensive for large or infinite iterables.

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

const generator = function* () {
  yield 1;
  yield 2;
  yield 3;
};

const original = I.iterable(generator);
const cloned = I.clone(original);

// Can iterate multiple times
const first = Array.from(cloned);  // [1, 2, 3]
const second = Array.from(cloned); // [1, 2, 3]
function clone<A>(ta: Iterable<A>): Iterable<A>;
§
clone<A>(ta: Iterable<A>): Iterable<A>
[src]

§Type Parameters

§Parameters

§
ta: Iterable<A>
[src]

§Return Type

§
Iterable<A>
[src]