repeat
import { repeat } from "jsr:@ende/bytes";function
function repeat(source: Uint8Array, count: number): Uint8Array_Returns a new byte slice composed of count repetitions of the source
array.
source: Uint8ArraySource array to repeat.
count: numberNumber of times to repeat the source array.
Returns
A new byte slice composed of count repetitions of the source
array.
Example: Basic usage
import { repeat } from "@ende/bytes/repeat";
import { assertEquals } from "@ende/assert";
const source = new Uint8Array([0, 1, 2]);
assertEquals(repeat(source, 3), new Uint8Array([0, 1, 2, 0, 1, 2, 0, 1, 2]));
Example: Zero count
import { repeat } from "@ende/bytes/repeat";
import { assertEquals } from "@ende/assert";
const source = new Uint8Array([0, 1, 2]);
assertEquals(repeat(source, 0), new Uint8Array());