Skip to main content

@std/bytes@1.0.4
Built and signed on GitHub Actions

Utilities to manipulate Uint8Arrays that are not built-in to JavaScript

This package works with Cloudflare Workers, Node.js, Deno, Bun, Browsers
This package works with Cloudflare Workers
This package works with Node.js
This package works with Deno
This package works with Bun
This package works with Browsers
JSR Score
100%
Published
a week ago (1.0.4)
function endsWith
endsWith(
source: Uint8Array,
suffix: Uint8Array,
): boolean

Returns true if the suffix array appears at the end of the source array, false otherwise.

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

Examples

Basic usage

import { endsWith } from "@std/bytes/ends-with";
import { assertEquals } from "@std/assert";

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

assertEquals(endsWith(source, suffix), true);

Parameters

source: Uint8Array

Source array to check.

suffix: Uint8Array

Suffix array to check for.

Return Type

true if the suffix array appears at the end of the source array, false otherwise.

Add Package

deno add jsr:@std/bytes

Import symbol

import { endsWith } from "@std/bytes/ends-with";

---- OR ----

Import directly with a jsr specifier

import { endsWith } from "jsr:@std/bytes/ends-with";

Add Package

npx jsr add @std/bytes

Import symbol

import { endsWith } from "@std/bytes/ends-with";

Add Package

yarn dlx jsr add @std/bytes

Import symbol

import { endsWith } from "@std/bytes/ends-with";

Add Package

pnpm dlx jsr add @std/bytes

Import symbol

import { endsWith } from "@std/bytes/ends-with";

Add Package

bunx jsr add @std/bytes

Import symbol

import { endsWith } from "@std/bytes/ends-with";