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

x/discord_rpc_deno/deps.ts>bytes.startsWith

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

Returns true if the prefix array appears at the start of the source array, false otherwise.

The complexity of this function is O(prefix.length).

Examples

Basic usage

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

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

startsWith(source, prefix); // true

Parameters

source: Uint8Array

Source array to check.

prefix: Uint8Array

Prefix array to check for.

Returns

boolean

true if the prefix array appears at the start of the source array, false otherwise.