{ } qjs-modules

node:buffer

Source: lib/node/buffer.js

Node's buffer module: Buffer, its constants, atob and btoa, as Bun and Deno provide it. Buffer is a Uint8Array subclass; every byte operation works on the underlying ArrayBuffer with absolute offsets.

import { Buffer } from 'node:buffer';

const b = Buffer.from('héllo');           // <Buffer 68 c3 a9 6c 6c 6f>
b.toString('hex');                        // '68c3a96c6c6f'
Buffer.concat([b, Buffer.alloc(2)]).length // 8

Encodings: utf8 (utf-8), utf16le (ucs2), latin1 (binary), ascii, base64, base64url, hex.

Export list

Generated by utilities/doc-api.js from the node_buffer dump of utilities/api-surface.sh: 116 members. Edit the text above this block, not the block.

Functions: SlowBuffer(), atob(), btoa(), isAscii(), isUtf8()

Values: INSPECT_MAX_BYTES = 50, kMaxLength = 9007199254740991, kStringMaxLength = 536870888

Buffer

class, constructible

  • static methods: alloc(), allocUnsafe(), allocUnsafeSlow(), byteLength(), compare(), concat(), copyBytesFrom(), from(), isBuffer(), isEncoding()
  • static values: poolSize = 8192
  • methods: compare(), copy(), equals(), fill(), includes(), indexOf(), lastIndexOf(), readBigInt64BE(), readBigInt64LE(), readBigUInt64BE(), readBigUInt64LE(), readBigUint64BE(), readBigUint64LE(), readDoubleBE(), readDoubleLE(), readFloatBE(), readFloatLE(), readInt16BE(), readInt16LE(), readInt32BE(), readInt32LE(), readInt8(), readIntBE(), readIntLE(), readUInt16BE(), readUInt16LE(), readUInt32BE(), readUInt32LE(), readUInt8(), readUIntBE(), readUIntLE(), readUint16BE(), readUint16LE(), readUint32BE(), readUint32LE(), readUint8(), readUintBE(), readUintLE(), slice(), swap16(), swap32(), swap64(), toJSON(), toLocaleString(), toString(), write(), writeBigInt64BE(), writeBigInt64LE(), writeBigUInt64BE(), writeBigUInt64LE(), writeBigUint64BE(), writeBigUint64LE(), writeDoubleBE(), writeDoubleLE(), writeFloatBE(), writeFloatLE(), writeInt16BE(), writeInt16LE(), writeInt32BE(), writeInt32LE(), writeInt8(), writeIntBE(), writeIntLE(), writeUInt16BE(), writeUInt16LE(), writeUInt32BE(), writeUInt32LE(), writeUInt8(), writeUIntBE(), writeUIntLE(), writeUint16BE(), writeUint16LE(), writeUint32BE(), writeUint32LE(), writeUint8(), writeUintBE(), writeUintLE(), [Symbol.for('nodejs.util.inspect.custom')]()
  • properties: offset (get), parent (get)

constants

object

  • static values: MAX_LENGTH = 9007199254740991, MAX_STRING_LENGTH = 536870888

default

object

  • static methods: Blob(), Buffer(), SlowBuffer(), atob(), btoa(), isAscii(), isUtf8()
  • static values: INSPECT_MAX_BYTES = 50, constants, kMaxLength = 9007199254740991, kStringMaxLength = 536870888