toBufferLE() function

Writes an unsigned bigint as a little-endian buffer of an exact size.

Signature:

export declare function toBufferLE(value: bigint, size: number): Buffer;

Parameters

Parameter

Type

Description

value

bigint

a non-negative value to encode

size

number

bytes in the resulting buffer; the result is always this long

Returns:

Buffer

A new buffer of exactly size bytes, zero-padded at the high end.

Exceptions

RangeError if size is not a positive integer, if value is negative, or if value needs more than size bytes. The size check happens after the bytes are written, so it catches overflow rather than silently truncating.

Remarks

The inverse of toBigIntLE(). Fixed width is the point: a network record holds two addresses at a known offset, so every address must occupy sizeOf() bytes whatever its magnitude.

Read this page as plain markdown — no HTML, no navigation. For pasting into an LLM, or for an agent to fetch.