buffer.writeIntLE()

buf.writeIntLE(value, offset, byteLength[, noAssert])

  • value <Number> Bytes to be written to Buffer
  • offset <Number> 0 <= offset <= buf.length - byteLength
  • byteLength <Number> 0 < byteLength <= 6
  • noAssert <Boolean> Default: false
  • Return: <Number> The offset plus the number of written bytes

Writes value to the Buffer at the specified offset and byteLength. Supports up to 48 bits of accuracy. For example:

const buf1 = Buffer.allocUnsafe(6);
buf1.writeUIntBE(0x1234567890ab, 0, 6);
console.log(buf1);
  // Prints: <Buffer 12 34 56 78 90 ab>

const buf2 = Buffer.allocUnsafe(6);
buf2.writeUIntLE(0x1234567890ab, 0, 6);
console.log(buf2);
  // Prints: <Buffer ab 90 78 56 34 12>

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.

Behavior is not defined when value is anything other than an integer.

doc_Nodejs
2016-04-30 04:37:48
Comments
Leave a Comment

Please login to continue.