Skip to main content
Home
This release is 28 versions behind 1.0.6 — the latest version of @std/bytes. Jump to latest
Works with
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 Score100%
Downloads49,405/wk
Published2 years ago (0.208.0)

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

// Copyright 2018-2023 the Deno authors. All rights reserved. MIT license. import { includesNeedle } from "./includes_needle.ts"; import { assert } from "jsr:@std/assert@^0.208.0"; Deno.test("[bytes] includesNeedle", () => { const encoder = new TextEncoder(); const source = encoder.encode("deno.land"); const pattern = encoder.encode("deno"); assert(includesNeedle(source, pattern)); assert(includesNeedle(new Uint8Array([0, 1, 2, 3]), new Uint8Array([2, 3]))); assert(includesNeedle(source, pattern, -10)); assert(!includesNeedle(source, pattern, -1)); });