Skip to main content
Deno 2 is finally here 🎉️
Learn more
Module

std/node/buffer.ts>Buffer.from

Deno standard library
Go to Latest
The Standard Library has been moved to JSR. See the blog post for details.
method Buffer.from
import { Buffer } from "https://deno.land/std@0.106.0/node/buffer.ts";

Allocates a new Buffer using an array of bytes in the range 0 – 255. Array entries outside that range will be truncated to fit into it.

Parameters

array: number[]

This creates a view of the ArrayBuffer without copying the underlying memory. For example, when passed a reference to the .buffer property of a TypedArray instance, the newly created Buffer will share the same allocated memory as the TypedArray.

Parameters

arrayBuffer: ArrayBuffer | SharedArrayBuffer
optional
byteOffset: number
optional
length: number

Copies the passed buffer data onto a new Buffer instance.

Parameters

buffer: Buffer | Uint8Array

Creates a new Buffer containing string.

Parameters

string: string
optional
encoding: string

Parameters

value: any
optional
offsetOrEncoding: number | string
optional
length: number