new RecordParser()
A helper class which allows you to easily parse protocols which are delimited by a sequence of bytes, or fixed
size records.
- Source:
Methods
delimitedMode(delim)
Flip the parser into delimited mode, and where the delimiter can be represented
by the delimiter
delim.
This method can be called multiple times with different values of delim while data is being parsed.
Parameters:
| Name | Type | Description |
|---|---|---|
delim |
Buffer | the new delimiter |
- Source:
endHandler(endHandler) → {RecordParser}
Parameters:
| Name | Type | Description |
|---|---|---|
endHandler |
function |
- Source:
Returns:
- Type
- RecordParser
exceptionHandler(handler) → {RecordParser}
Parameters:
| Name | Type | Description |
|---|---|---|
handler |
function |
- Source:
Returns:
- Type
- RecordParser
fetch(amount) → {RecordParser}
Parameters:
| Name | Type | Description |
|---|---|---|
amount |
number |
- Source:
Returns:
- Type
- RecordParser
fixedSizeMode(size)
Flip the parser into fixed size mode, where the record size is specified by
size in bytes.
This method can be called multiple times with different values of size while data is being parsed.
Parameters:
| Name | Type | Description |
|---|---|---|
size |
number | the new record size |
- Source:
handle(buffer)
This method is called to provide the parser with data.
Parameters:
| Name | Type | Description |
|---|---|---|
buffer |
Buffer | a chunk of data |
- Source:
handler(handler) → {RecordParser}
Parameters:
| Name | Type | Description |
|---|---|---|
handler |
function |
- Source:
Returns:
- Type
- RecordParser
maxRecordSize(size) → {RecordParser}
Set the maximum allowed size for a record when using the delimited mode.
The delimiter itself does not count for the record size.
If a record is longer than specified, an IllegalStateException will be thrown.
Parameters:
| Name | Type | Description |
|---|---|---|
size |
number | the maximum record size |
- Source:
Returns:
a reference to this, so the API can be used fluently
- Type
- RecordParser
pause() → {RecordParser}
- Source:
Returns:
- Type
- RecordParser
pipe() → {Pipe}
Pause this stream and return a to transfer the elements of this stream to a destination .
The stream will be resumed when the pipe will be wired to a
WriteStream.
- Source:
Returns:
a pipe
- Type
- Pipe
pipeTo(dst, handler)
Pipe this
ReadStream to the WriteStream.
Elements emitted by this stream will be written to the write stream until this stream ends or fails.
Once this stream has ended or failed, the write stream will be ended and the handler will be
called with the result.
Parameters:
| Name | Type | Description |
|---|---|---|
dst |
WriteStream | the destination write stream |
handler |
function |
- Source:
resume() → {RecordParser}
- Source:
Returns:
- Type
- RecordParser
setOutput(output)
Parameters:
| Name | Type | Description |
|---|---|---|
output |
function |
- Source: