• Convert BigInt to big-endian bytes, writing directly into a provided buffer. This is an optimized version that avoids buffer allocation.

    Parameters

    • num: bigint

      BigInt value to convert

    • buffer: Buffer<ArrayBufferLike> | Uint8Array<ArrayBufferLike>

      Pre-allocated buffer to write into (width is inferred from length)

    Returns void

    const buf = Buffer.alloc(4);
    toBufferBEInto(16909060n, buf);
    // buf is now [0x01, 0x02, 0x03, 0x04]