Function repeat

  • Returns a new byte slice composed of count repetitions of the source array.

    Parameters

    • source: Uint8Array

      Source array to repeat.

    • count: number

      Number of times to repeat the source array.

    Returns Uint8Array_

    A new byte slice composed of count repetitions of the source array.

    import { repeat } from "@std/bytes/repeat";
    import { assertEquals } from "@std/assert";

    const source = new Uint8Array([0, 1, 2]);

    assertEquals(repeat(source, 3), new Uint8Array([0, 1, 2, 0, 1, 2, 0, 1, 2]));
    import { repeat } from "@std/bytes/repeat";
    import { assertEquals } from "@std/assert";

    const source = new Uint8Array([0, 1, 2]);

    assertEquals(repeat(source, 0), new Uint8Array());