Write to a buffer without maintaining an offset or knowing its length.
- This module tries to mirror Buffer methods for simplicity.
- Supports writing 64-bit values at 52-bit precision (JavaScript safe integer maximum).
npm install buffer-write varWriter=require('buffer-write');// Normal methodvarwriter=newWriter()writer.write('a')writer.fill(1,3)writer.writeInt8(0x72)writer.toBuffer();// <Buffer 61 01 01 01 72>// Chain methodWriter().writeUInt16BE(0x7623).write(newBuffer([1,2,3,4]),2).writeUInt16LE(0x1800).toBuffer();// <Buffer 76 23 01 02 00 18>NOTE: There is no concept of offset when using this module as values are effectively appended to each other.
Write an integer of the specified size and endian format. A RangeError will be thrown for any out of range values. 64-bit integer methods will only accept 52-bit integer values.
Write a floating point number of the specified size and endian format.
Write a string of specified length and encoding.
Write a buffer or part of a buffer.
Fill with length repetitions of the specified value.
The number of bytes currently written.
Write our values into an existing buffer.
Create a new buffer and write our values.
MIT