2021-12-07 13:18:08 -05:00

11 lines
244 B
JavaScript

const MAX_INT32 = Math.pow(2, 32)
module.exports = (value, buf = Buffer.allocUnsafe(8)) => {
const high = Math.floor(value / MAX_INT32)
const low = value % MAX_INT32
buf.writeUInt32BE(high, 0)
buf.writeUInt32BE(low, 4)
return buf
}