Skip to main content
Module

x/web_bson/deps.ts>startsWith

web_bson is a fork from mongodb/js-bson
Very Popular
Go to Latest
function startsWith
import { startsWith } from "https://deno.land/x/web_bson@v0.2.4/deps.ts";

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).

import { startsWith } from "./mod.ts";
const source = new Uint8Array([0, 1, 2, 1, 2, 1, 2, 3]);
const prefix = new Uint8Array([0, 1, 2]);
console.log(startsWith(source, prefix)); // true

Parameters

source: Uint8Array
prefix: Uint8Array

Returns

boolean