This release is 39 versions behind 1.0.6 — the latest version of @std/bytes. Jump to latest
Utilities to manipulate Uint8Arrays that are not built-in to JavaScript
This package works with Cloudflare Workers, Node.js, Deno, Bun, Browsers




JSR Score
100%
Published
2 years ago (0.197.0)
// Copyright 2018-2023 the Deno authors. All rights reserved. MIT license. // This module is browser compatible. /** Concatenate the given arrays into a new Uint8Array. * * ```ts * import { concat } from "@std/bytes/concat"; * const a = new Uint8Array([0, 1, 2]); * const b = new Uint8Array([3, 4, 5]); * console.log(concat(a, b)); // [0, 1, 2, 3, 4, 5] */ export function concat(...buf: Uint8Array[]): Uint8Array { let length = 0; for (const b of buf) { length += b.length; } const output = new Uint8Array(length); let index = 0; for (const b of buf) { output.set(b, index); index += b.length; } return output; }