Skip to main content
Deno 2 is finally here 🎉️
Learn more
Module

x/discord_rpc_deno/deps.ts>bytes.repeat

port of @xhayper/discord-rpc to deno
Latest
function bytes.repeat
import { bytes } from "https://deno.land/x/discord_rpc_deno@v1.1.4/deps.ts";
const { repeat } = bytes;

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

Examples

Basic usage

import { repeat } from "https://deno.land/std@0.224.0/bytes/repeat.ts";

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

repeat(source, 3); // Uint8Array(9) [0, 1, 2, 0, 1, 2, 0, 1, 2]

repeat(source, 0); // Uint8Array(0) []

repeat(source, -1); // Throws `RangeError`

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.