• Takes only the prefix of length count. If count >= length(list), the list itself will be returned.

    Parameters

    • count: number

      The length to take.

    Returns (<T>(list) => List<T>)

    The taken list.

    Examples

    import { range, take, toIterator } from "./list.ts";
    import { assertEquals } from "../deps.ts";

    const taken = take(2)(range(1, 6));
    const iter = toIterator(taken);
    assertEquals(iter.next(), { value: 1, done: false });
    assertEquals(iter.next(), { value: 2, done: false });
    assertEquals(iter.next(), { value: undefined, done: true });
      • <T>(list): List<T>
      • Type Parameters

        • T

        Parameters

        Returns List<T>

Generated using TypeDoc