NiceBuffer
Wraps Node's Buffer class by providing smart defaults specific to the JVM's binary format.
Constructor Summary
Public Constructor | ||
public |
constructor(buffer: Buffer) Instantiates a new instance |
Member Summary
Public Members | ||
public |
buffer: Buffer |
|
public |
Maps size constants to their respective method names. |
|
public |
Current position in buffer. |
Method Summary
Public Methods | ||
public |
Reads an unsigned 8bit Integer from the buffer. |
|
public |
Reads an unsigned 32bit Integer from the buffer in Big Endian format. |
|
public |
Moves the offset used when reading/writing bytes by a relative amount. |
|
public |
Reads an arbitrary amount of bytes from the buffer. |
|
public |
readStruct(struct: *): * |
|
public |
Reads an unsigned 16bit Integer from the buffer in Big Endian format. |
|
public |
Slice a Buffer of bytes from the buffer of a specified length at the current position. |
|
public |
Writes an array of bytes to the current position in the buffer. |
|
public |
Writes a single ubyte to the current position in the buffer. |
|
public |
Writes a uint to the current position in the buffer in Big Endian format. |
|
public |
writeShort(val: Number) Writes a ushort to the current position in the buffer in Big Endian format. |
Public Constructors
public constructor(buffer: Buffer) source
Instantiates a new instance
Params:
Name | Type | Attribute | Description |
buffer | Buffer | normal Node Buffer object |
Public Members
public buffer: Buffer source
Public Methods
public move(len: Number): Number source
Moves the offset used when reading/writing bytes by a relative amount.
Params:
Name | Type | Attribute | Description |
len | Number | Relative offset to move |
Return:
Number | The position before the offset is added to it.
Behavior is similar to |
public read(len: Number): Number | Buffer source
Reads an arbitrary amount of bytes from the buffer.
If the length matches one of the SIZE_
prefixed constants
also declared in this class, it will instead decode the bytes into
an unsigned integer of that size.
Params:
Name | Type | Attribute | Description |
len | Number | Number of bytes to read. |
public slice(len: Number): Buffer source
Slice a Buffer of bytes from the buffer of a specified length at the current position.
Params:
Name | Type | Attribute | Description |
len | Number | Number of bytes to slice |
Return:
Buffer |
public write(bytes: Array<Number>) source
Writes an array of bytes to the current position in the buffer.
public writeByte(val: Number) source
Writes a single ubyte to the current position in the buffer.
Params:
Name | Type | Attribute | Description |
val | Number |