Skip to main content

Module buffer

Module buffer 

Source
Expand description

Node Buffer (global + require('buffer').Buffer). A Buffer is a plain object tagged @@native = "Buffer" whose bytes live in a hidden @@bytes array SHARED with its ArrayBuffer (@@buffer, read as buf.buffer); the Buffer is a window (byteOffset/length) onto it, so every reader goes through window_bytes_h.

Constants§

BLOB_METHODS
Method names for Blob/File instances (parent instance_has_method).
INSTANCE_METHODS
The methods a Buffer instance answers — the surface instance_call dispatches, and the set installed as @proto:Buffer:<m> thunks on the real Buffer.prototype object.
MODULE_METHODS
Free functions of the buffer module itself (require('buffer').atob, …), as opposed to the Buffer constructor’s static methods above. Needs the parent "buffer" routing arm (see final report).
STATIC_METHODS
The statics on Buffer. node v26.7.0’s Object.getOwnPropertyNames(Buffer).filter(n => typeof Buffer[n] === 'function') reports eleven; this is ten of them.

Functions§

blob_call
Blob/File instance methods. text/arrayBuffer/bytes return already- resolved Promises (Node’s async accessors); slice returns a new Blob. arrayBuffer/bytes resolve with a Buffer (this runtime’s byte container) rather than a bare ArrayBuffer/Uint8Array.
byte_get
buf[i] — the byte at an integer index, or undefined past the end.
byte_set
buf[i] = n — write one byte (truncated to 8 bits, as a Uint8Array does). Returns whether recv was a Buffer and the write landed.
bytes_like
construct_blob
new Blob(parts[, options]).
construct_file
new File(parts, name[, options]).
from_bytes
Build a Buffer value from raw bytes.
instance_call
Buffer instance methods.
module_call
Dispatch a require('buffer').<method> free function.
module_constant
The data members of the buffer module, next to its functions. MAX_STRING_LENGTH is V8’s String::kMaxLength on a 64-bit build, the figure node reports; node-js does not itself cap a string at it.
pooled
allocate(size) / fromArrayLike: a pooled Buffer holding bytes when it is non-empty and under half the pool size, an own allocation otherwise.
share_array_buffer
A Buffer that is a WINDOW onto an existing ArrayBuffer’s store, sharing its bytes rather than copying them.
static_call
view_bytes
The bytes of any byte-like source: a JS array of byte values, another Buffer, ANY typed array, or an ArrayBuffer. None for anything else (a string, which every caller handles with its own encoding rules).
window_bytes_h
The bytes a Buffer’s window covers, with the host borrow held. Every reader of a Buffer’s bytes goes through here: the store is SHARED with its ArrayBuffer and with every other view over it, so reading the whole store returns bytes that are not the Buffer’s.
window_h
window over a Buffer’s own properties, with the host borrow held.
write_view
Overwrite the bytes a byte VIEW (or an ArrayBuffer) exposes, from its first byte — the write-side twin of view_bytes, so an API that fills a caller’s view (randomFillSync, readSync) reaches every view kind and the memory it aliases.