Scramjet main exports expose all the stream classes and a number of methods.
All scramjet streams allow writing, reading or transform modes - currently exclusively (meaning you can't have two at once). Any of the scramjet streams can be constructed with the following options passed to mimic node.js standard streams:
async promiseTransform(chunk)
- transform method that resolves with a single output chunkasync promiseWrite(chunk)
- write method that that resolves when chunk is writtenasync promiseRead(count)
- read method that resolves with an array of chunks when called
See node.js API for stream implementers for details
The object exposes the following classes:
DataStream
{@see DataStream} - the basic object stream of any typeStringStream
{@see StringStream} - a stream of stringsBufferStream
{@see BufferStream} - a stream of buffersMultiStream
{@see MultiStream} - a group of streamsNumberStream
{@see NumberStream} - a stream of numbersWindowStream
{@see WindowStream} - a stream of windows of objects
The general concept of Scramjet streams is facilitating node's TransformStream mechanism so that you don't need
to create a number of streams and create the pipeline, but use the concept of chaining instead. When you call parse
method for instance, scramjet creates a new stream, pipes it to the callee and forwards errors.
What's worth mentioning - scramjet tries to limit the number of created transform streams and pushes the transforms
one after another into the same stream class therefore a code stream.map(transform1).map(transform2).filter(transform3)
will only operate on a single transform stream that evaluates all three transforms one after another.
- scramjet
- :from(input, [options])
DataStream
- :fromArray(array, [options])
DataStream
- :createTransformModule(transform, [options])
function
- :createReadModule(anything, [options])
function
- :plugin(mixin)
ScramjetPlugin
- :API(version)
ScramjetPlugin
- ~CreateModuleOptions
object
- ~StreamMixin
object
- ~ScramjetPlugin
object
- :from(input, [options])
Creates a DataStream that's piped from the passed readable.
Kind: static method of scramjet
Param | Type | Default | Description |
---|---|---|---|
input | Array | Iterable.<any> | AsyncGeneratorFunction | GeneratorFunction | AsyncFunction | function | string | Readable |
argument to be turned into new stream | |
[options] | DataStreamOptions | Writable |
{} |
options for creation of a new stream or the target stream |
...args | Array.<any> |
additional arguments for the stream - will be passed to the function or generator |
Creates a DataStream from an Array
Kind: static method of scramjet
Param | Type | Default | Description |
---|---|---|---|
array | Array |
list of chunks | |
[options] | DataStreamOptions |
{} |
the read stream options |
Creates a safe wrapper for scramjet transform module. See Modules documentation for more info.
Kind: static method of scramjet
Returns: function
- a scramjet module function
Param | Type | Default |
---|---|---|
transform | UseCallback |
|
[options] | CreateModuleOptions |
{} |
...initialArgs | Array.<any> |
Creates a safe wrapper for scramjet read module. See Modules documentation for more info.
Kind: static method of scramjet
Returns: function
- a scramjet module function
Param | Type | Default |
---|---|---|
anything | Array | Iterable.<any> | AsyncGeneratorFunction | GeneratorFunction | AsyncFunction | function | string | Readable |
|
[options] | CreateModuleOptions |
{} |
...initialArgs | Array.<any> |
Plugs in methods for any of the classes
Kind: static method of scramjet
Test: test/methods/scramjet-plugin.js
Param | Type | Description |
---|---|---|
mixin | ScramjetPlugin |
the plugin object |
Gets an API version (this may be important for future use)
Kind: static method of scramjet
Param | Type | Description |
---|---|---|
version | number |
The required version (currently only: 1) |
Options for createModule
Kind: inner typedef of scramjet
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 of scramjet
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 of scramjet
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. |