Skip to main content

@std/bytes@0.215.0

latest
Works with
It is unknown whether this package works with Browsers, Deno, Node.js, Cloudflare Workers, Bun
It is unknown whether this package works with Browsers
It is unknown whether this package works with Deno
It is unknown whether this package works with Node.js
It is unknown whether this package works with Cloudflare Workers
It is unknown whether this package works with Bun
JSR Score70%
Published2 years ago (0.215.0)
function copy
copy(
off?
): number

Copy bytes from the src array to the dst array. Returns the number of bytes copied.

If the src array is larger than what the dst array can hold, only the amount of bytes that fit in the dst array are copied.

An offset can be specified as the third argument that begins the copy at that given index in the dst array. The offset defaults to the beginning of the array.

import { copy } from "@std/bytes/copy";
const src = new Uint8Array([9, 8, 7]);
const dst = new Uint8Array([0, 1, 2, 3, 4, 5]);
console.log(copy(src, dst)); // 3
console.log(dst); // [9, 8, 7, 3, 4, 5]
import { copy } from "@std/bytes/copy";
const src = new Uint8Array([1, 1, 1, 1]);
const dst = new Uint8Array([0, 0, 0, 0]);
console.log(copy(src, dst, 1)); // 3
console.log(dst); // [0, 1, 1, 1]

Parameters

Return Type

Report package

Please provide a reason for reporting this package. We will review your report and take appropriate action.

Please review the JSR usage policy before submitting a report.

Add Package

deno add jsr:@std/bytes

Import symbol

import { copy } from "@std/bytes";
or

Import directly with a jsr specifier

import { copy } from "jsr:@std/bytes";