Shift Function
Kind: inner typedef
| Param | Type | Description |
|---|---|---|
| shifted | Buffer | any |
shifted bytes |
Kind: inner typedef
Returns: Promise.<any> | any - the promise should be resolved with the parsed object
| Param | Type | Description |
|---|---|---|
| chunk | Buffer |
the transformed chunk |
Kind: inner typedef
Returns: Promise.<any> | any - the mapped object
| Param | Type | Description |
|---|---|---|
| chunk | any |
the chunk to be mapped |
Kind: inner typedef
Returns: Promise.<Boolean> | Boolean - information if the object should remain in the filtered stream.
| Param | Type | Description |
|---|---|---|
| chunk | any |
the chunk to be filtered or not |
Kind: inner typedef
Returns: Promise.<any> | any - accumulator for the next pass
| Param | Type | Description |
|---|---|---|
| accumulator | any |
the accumulator - the object initially passed or returned by the previous reduce operation |
| chunk | object |
the stream chunk. |
Kind: inner typedef
Returns: Promise.<any> | any - the outcome is discarded
| Param | Type | Description |
|---|---|---|
| chunk | object |
source stream chunk |
Kind: inner typedef
Returns: Promise.<any> | any - resolution for the old stream (for flow control only)
| Param | Type | Description |
|---|---|---|
| into | * |
stream passed to the into method |
| chunk | any |
source stream chunk |
Kind: inner typedef
| Param | Type |
|---|---|
| stream | DataStream |
| ...parameters | Array.<any> |
Kind: inner typedef
| Param | Type | Description |
|---|---|---|
| teed | DataStream |
The teed stream |
Transform async callback. The passed transform should return a new chunk, unless
the output should be filtered - if so, the transform should return undefined.
Additionally the function can reject with DataStream.filter - the result will be
filtered and no other transforms will be run on the chunk.
Kind: inner typedef
Returns: Promise.<(any|undefined)> | any | undefined - the result, undefined will be treated as filtered out.
| Param | Type | Description |
|---|---|---|
| chunk | Buffer | string | any |
the stream chunk |
| encoding | string |
encoding of the chunk |
Write async callback. Await your async write and resolve.
Kind: inner typedef
Returns: Promise.<void> | void - should resolve when the write ends
| Param | Type | Description |
|---|---|---|
| chunk | Buffer | string | any |
the stream chunk |
| encoding | string |
encoding of the chunk |
Read async callback. Simply await your async operations and return the result as array.
Kind: inner typedef
Returns: Array.<any> | Promise.<Array.<any>> - the read chunk.
| Param | Type | Description |
|---|---|---|
| count | number |
the number of chunks that should be read ("this is more like a set of guideline than actual rules"). |
Standard options for scramjet streams.
Defines async transforms or read/write methods for a stream.
Kind: inner typedef
Properties
| Name | Type | Default | Description |
|---|---|---|---|
| [promiseRead] | ScramjetReadCallback |
|
an async function returning the next read item |
| [promiseWrite] | ScramjetWriteCallback |
|
an async function writing the next written item |
| [promiseTransform] | ScramjetTransformCallback |
|
an async function returning a transformed chunk |
| [promiseFlush] | ScramjetReadCallback |
|
an async function run before transform stream ends to push last chunks from the buffer |
| [beforeTransform] | ScramjetTransformCallback |
|
an async function run before the transform |
| [afterTransform] | ScramjetTransformCallback |
|
an async function run after the transform |
| [maxParallel] | number |
os.cpus.length*2 |
the number of transforms done in parallel |
| [referrer] | DataStream |
|
a referring stream to point to (if possible the transforms will be pushed to it |
| [objectMode] | boolean |
true |
should the object mode be used instead of creating a new stream) |
| [highWaterMark] | number |
The maximum number of bytes to store in the internal buffer before ceasing to read from the underlying resource. Default: 16384 (16KB), or 16 for objectMode streams. | |
| [encoding] | string |
If specified, then buffers will be decoded to strings using the specified encoding. Default: null. | |
| [emitClose] | boolean |
Whether or not the stream should emit 'close' after it has been destroyed. Default: true. | |
| [read] | function |
Implementation for the stream._read() method. | |
| [destroy] | function |
Implementation for the stream._destroy() method. | |
| [construct] | function |
Implementation for the stream._construct() method. | |
| [autoDestroy] | boolean |
Whether this stream should automatically call .destroy() on itself after ending. Default: true. |
Shift Function
Kind: inner typedef
| Param | Type | Description |
|---|---|---|
| shifted | Array.<object> | any |
an array of shifted chunks |
Kind: inner typedef
Returns: Promise.<any> | * - resolved when all operations are completed
| Param | Type | Description |
|---|---|---|
| accumulator | * |
Accumulator passed to accumulate function |
| chunk | * |
the stream chunk |
Kind: inner typedef
Returns: Promise.<any> | * - resolved when all operations are completed
| Param | Type | Description |
|---|---|---|
| chunk | * |
the stream chunk |
Kind: inner typedef
Returns: Promise.<any> | * - promise to be resolved when chunk has been processed
| Param | Type | Description |
|---|---|---|
| emit | function |
a method to emit objects in the remapped stream |
| chunk | * |
the chunk from the original stream |
Kind: inner typedef
Returns: AsyncGenerator.<any, void, any> | Promise.<Iterable.<any>> | Iterable.<any> - promise to be resolved when chunk has been processed
| Param | Type | Description |
|---|---|---|
| chunk | * |
the chunk from the original stream |
Kind: inner typedef
Returns: Promise.<*> | * - promise that is resolved with the joining item
| Param | Type | Description |
|---|---|---|
| previous | * |
the chunk before |
| next | * |
the chunk after |
Kind: inner typedef
| Param | Type |
|---|---|
| chunk | * |
Kind: inner typedef
| Param | Type | Default | Description |
|---|---|---|---|
| [timeFrame] | number |
1000 |
The size of the window to look for streams. |
| [getTime] | function |
Date.now |
Time source - anything that returns time. |
| [setTimeout] | function |
setTimeout |
Timing function that works identically to setTimeout. |
Kind: inner typedef
Extends: StringStream.ExecOptions
Properties
| Name | Type | Description |
|---|---|---|
| [parse] | UseCallback |
scramjet module to transform the stream to string or buffer stream |
| [stringify] | UseCallback |
scramjet module to transform from string or buffer stream to wanted version |
Options for createModule
Kind: inner typedef
Properties
| Name | Type | Description |
|---|---|---|
| StreamClass | DataStream |
defines what class should the module assume |
Definition of a single mixin for a specific Scramjet class. Should contain any number of stream methods.
Kind: inner typedef
Properties
| Name | Type | Description |
|---|---|---|
| constructor | function |
optional constructor that will be called in the stream constructor (this has to be an own property!) |
Definition of a plugin in Scramjet
Kind: inner typedef
Internal:
Properties
| Name | Type | Description |
|---|---|---|
| BufferStream | StreamMixin |
definition of constructor and properties for the BufferStream prototype. |
| DataStream | StreamMixin |
definition of constructor and properties for the DataStream prototype. |
| MultiStream | StreamMixin |
definition of constructor and properties for the MultiStream prototype. |
| StringStream | StreamMixin |
definition of constructor and properties for the StringStream prototype. |
Kind: inner typedef
| Param | Type |
|---|---|
| stream | DataStream |
Distribute options
Kind: inner typedef
Properties
| Name | Type | Default | Description |
|---|---|---|---|
| [plugins] | Array |
[] |
a list of scramjet plugins to load (if omitted, will use just the ones in scramjet itself) |
| [StreamClass] | string |
"DataStream" |
the class to deserialize the stream to. |
| [threads] | number |
os.cpus().length * 2 |
maximum threads to use - defaults to number of processor threads in os, but it may be sensible to go over this value if you'd intend to run synchronous code. |
| [createOptions] | DataStreamOptions |
{} |
maximum threads to use - defaults to number of processor threads in os, but it may be sensible to go over this value if you'd intend to run synchronous code. |
| [StreamWorker] | StreamWorker |
scramjet.StreamWorker |
worker implementation. |
Kind: inner typedef
Returns: Promise.<number> | number - value of the object
| Param | Type | Description |
|---|---|---|
| chunk | * |
stream object |
NumberStream options
Kind: inner typedef
Extends: DataStreamOptions
Properties
| Name | Type | Default | Description |
|---|---|---|---|
| [valueOf] | ValueOfCallback |
x => +x |
value of the data item function. |
Kind: inner typedef
| Param | Type | Description |
|---|---|---|
| shifted | string | any |
Shifted chars |
Kind: inner typedef
Returns: Promise.<any> | any - the promise should be resolved with the parsed object
| Param | Type | Description |
|---|---|---|
| chunk | string |
the transformed chunk |
Kind: inner typedef
Extends: child_process.SpawnOptions
Properties
| Name | Type | Default | Description |
|---|---|---|---|
| [stream] | number |
1 |
(bitwise) the output stdio number to push out (defaults to stdout = 1) |
| [interpreter] | Array.<string> |
[] |
defaults to nothing, except on windows where "cmd.exe /c" will be spawned by default |