Constructor
new FrameReader(body)
Creates a new instance of the reader
Parameters:
| Name | Type | Description |
|---|---|---|
body |
Buffer |
Methods
checkOffset(newLength)
Checks that the new length to read is within the range of the buffer length. Throws a RangeError if not.
Parameters:
| Name | Type | Description |
|---|---|---|
newLength |
Number |
read(length) → {Buffer}
Reads any number of bytes and moves the offset. if length not provided or it's larger than the remaining bytes, reads to end.
Parameters:
| Name | Type | Description |
|---|---|---|
length |
Returns:
- Type
- Buffer
readBytes() → {Buffer}
Reads the amount of bytes that the field has and returns them (slicing them).
Returns:
- Type
- Buffer
readInt() → {Number}
Reads a BE Int and moves the offset
Returns:
- Type
- Number
slice(begin, endopt) → {Buffer}
Slices the underlying buffer
Parameters:
| Name | Type | Attributes | Description |
|---|---|---|---|
begin |
Number | ||
end |
Number |
<optional> |
Returns:
- Type
- Buffer