- ScramjetCore
- ~BufferStream ⇐
DataStream
- new BufferStream(opts)
- .shift(chars, func) ⇒
BufferStream
- .split(splitter) ⇒
BufferStream
- .breakup(number) ⇒
BufferStream
- .stringify(encoding) ⇒
StringStream
- .parse(parser) ⇒
DataStream
- ~toStringStream()
- ~toDataStream()
- ~PopCallback :
function
- ~ParseCallback ⇒
Promise
- ~BufferStream ⇐
A factilitation stream created for easy splitting or parsing buffers
Kind: inner class of ScramjetCore
Extends: DataStream
- ~BufferStream ⇐
DataStream
- new BufferStream(opts)
- .shift(chars, func) ⇒
BufferStream
- .split(splitter) ⇒
BufferStream
- .breakup(number) ⇒
BufferStream
- .stringify(encoding) ⇒
StringStream
- .parse(parser) ⇒
DataStream
Creates the BufferStream
Param | Type | Description |
---|---|---|
opts | object |
Stream options passed to superclass |
Example
[../samples/buffer-stream-constructor.js](../samples/buffer-stream-constructor.js)
Shift given number of bytes from the original stream
Works the same way as {@see DataStream.shift}, but in this case extracts the given number of bytes.
Kind: instance method of BufferStream
Returns: BufferStream
- substream
Param | Type | Description |
---|---|---|
chars | Number |
The number of bytes to shift |
func | PopCallback |
Function that receives a string of shifted bytes |
Example
[../samples/string-stream-shift.js](../samples/string-stream-shift.js)
Splits the buffer stream into buffer objects
Kind: instance method of BufferStream
Returns: BufferStream
- the re-splitted buffer stream.
Todo
- implement splitting by function
Param | Type | Description |
---|---|---|
splitter | String | Buffer |
the buffer or string that the stream should be split by. |
Example
[../samples/buffer-stream-split.js](../samples/buffer-stream-split.js)
Breaks up a stream apart into chunks of the specified length
Kind: instance method of BufferStream
Returns: BufferStream
- the resulting buffer stream.
Param | Type | Description |
---|---|---|
number | Number |
the desired chunk length |
Example
[../samples/buffer-stream-breakup.js](../samples/buffer-stream-breakup.js)
Creates a string stream from the given buffer stream
Still it returns a DataStream derivative and isn't the typical node.js stream so you can do all your transforms when you like.
Kind: instance method of BufferStream
Returns: StringStream
- The converted stream.
Param | Type | Description |
---|---|---|
encoding | String |
The encoding to be used to convert the buffers to streams. |
Example
[../samples/buffer-stream-tostringstream.js](../samples/buffer-stream-tostringstream.js)
Parses every buffer to object
The method MUST parse EVERY buffer into a single object, so the buffer stream here should already be splitted or broken up.
Kind: instance method of BufferStream
Returns: DataStream
- The parsed objects stream.
Param | Type | Description |
---|---|---|
parser | ParseCallback |
The transform function |
Example
[../samples/buffer-stream-parse.js](../samples/buffer-stream-parse.js)
Alias for BufferStream#stringify
Kind: inner method of ScramjetCore
Alias for BufferStream#parse
Kind: inner method of ScramjetCore
Pop callback
Kind: inner typedef of ScramjetCore
Param | Type | Description |
---|---|---|
popped | Buffer |
popped bytes |
Kind: inner typedef of ScramjetCore
Returns: Promise
- the promise should be resolved with the parsed object
Param | Type | Description |
---|---|---|
chunk | Buffer |
the transformed chunk |