buffer-read
Read values from a buffer without maintaining an offset. Useful when you don't want to maintain an offset yourself.
- This module tries to mirror Buffer methods for simplicity.
- Supports reading 64-bit values at 52-bit precision (JavaScript safe integer maximum).
Install
npm install buffer-read
Usage
var Reader = ; var reader = '6101010172010203' 'hex';reader; // 'a'readeroffset += 3; // Skip over 3 bytesreader // 0x72reader // <Buffer 01 02 03>
API
read[U]Int8(), read[U]{16,32,64}{BE,LE}()
Read an integer of the specified size and endian format.
readFloat{BE,LE}(), readDouble{BE,LE}()
Read a floating point number of the specified size and endian format.
toString([encoding], [length])
Read a string of specified length and encoding.
slice([length])
Create a slice of the buffer.
offset
The current byte offset.
copy(targetBuffer, [length], [targetStart])
Copy data into another buffer.
License
MIT