Convert BigInt to big-endian bytes, writing directly into a provided buffer. This is an optimized version that avoids buffer allocation.
BigInt value to convert
Pre-allocated buffer to write into (width is inferred from length)
const buf = Buffer.alloc(4);toBufferBEInto(16909060n, buf);// buf is now [0x01, 0x02, 0x03, 0x04] Copy
const buf = Buffer.alloc(4);toBufferBEInto(16909060n, buf);// buf is now [0x01, 0x02, 0x03, 0x04]
Convert BigInt to big-endian bytes, writing directly into a provided buffer. This is an optimized version that avoids buffer allocation.