buf.writeUInt16LE(value, offset[, noAssert])
Writes value
to the Buffer at the specified offset
with specified endian format (writeUInt16BE()
writes big endian, writeUInt16LE()
writes little endian). The value
should be a valid unsigned 16-bit integer. Behavior is not defined when value
is anything other than an unsigned 16-bit integer.
Set noAssert
to true to skip validation of value
and offset
. This means that value
may be too large for the specific function and offset
may be beyond the end of the Buffer leading to the values being silently dropped. This should not be used unless you are certain of correctness.
Example:
const buf = Buffer.allocUnsafe(4); buf.writeUInt16BE(0xdead, 0); buf.writeUInt16BE(0xbeef, 2); console.log(buf); // Prints: <Buffer de ad be ef> buf.writeUInt16LE(0xdead, 0); buf.writeUInt16LE(0xbeef, 2); console.log(buf); // Prints: <Buffer ad de ef be>
Please login to continue.