What is Deno.Buffer?
What is Deno?
Deno is a small general-purpose runtime environment for JavaScript with first-class support for various interfaces, ECMAScript modules, and seamless TypeScript integration.
Deno.Buffer
Deno.Buffer is a variable-sized buffer of bytes with read() and write() methods implemented on top of an ArrayBuffer that is also a fixed memory allocation. It is mostly used with input/output sockets and files. Like other buffers, it also allows the buffer to download from sockets and grow/shrink accordingly.
Constructors
constructor(ab?: ArrayBuffer)
Properties
readonly length: number
// This is used to read a specific number of bytes from a buffer.
readonly capacity: number
// The total space allocated to the buffer to store the data.
Methods
bytes(options?: { copy: boolean }): Uint8Array
/*
Returns the part of the buffer which is unread at that time.
If `options.copy` is false, this part which is also called a slice, it aliases the buffer content until the next buffer modification.*/
param options Defaults to { copy: true }
empty(): boolean
// Returns whether the unread portion of the buffer is empty or not.
truncate(n: number): void
// Discards all but the first n unread bytes from the buffer.
reset(): void
// Resets the buffer to be empty.
readSync(p: Uint8Array): number | null
// Reads the next p.length bytes from the buffer.
// This returns the number of bytes read.
// Returns null if buffer empty.
read(p: Uint8Array): Promise<number | null>
// Reads the next p.length bytes from the buffer.
// This function resolves to the number of bytes read.
// Returns null if buffer empty.
writeSync(p: Uint8Array): number
write(p: Uint8Array): Promise<number>
// Writes the next p.length bytes into the buffer.
grow(n: number): void
// Grows the buffer's capacity to at least n bytes.
readFrom(r: Reader): Promise<number>
// Reads data from r until end of file(null).
// It appends the data into the buffer.
// It also resolves to the number of bytes read.
readFromSync(r: ReaderSync): number
// Reads data from r until end of file(null).
// It appends the data into the buffer.
// It returns the number of bytes read.
Free Resources
Copyright ©2026 Educative, Inc. All rights reserved