Fast, asynchronous, functional reactive stream programming framework with multi‑threading capability based on ES6+.

Master Build StatusMaster Build StatusDependenciesDev DependenciesKnown VulnerabilitiesDeepScan grade
Module exports
Classes
  • StringStream : DataStream

    A stream of string objects for further transformation on top of DataStream.

    Example:

    StringStream.fromString()

    Kind: global class
    Extends: DataStream

    new StringStream(encoding)

    Constructs the stream with the given encoding

    Param Type Description
    encoding String the encoding to use

    stringStream.toStringStream()

    Alias for stringify

    Kind: instance method of StringStream
    Overrides: toStringStream

    stringStream.shift(bytes, func) ↺

    Shifts given length of chars from the original stream

    Works the same way as {@see DataStream.shift}, but in this case extracts the given number of characters.

    Kind: instance method of StringStream
    Chainable
    Overrides: shift
    Test: test/methods/string-stream-shift.js

    Param Type Description
    bytes Number The number of characters to shift.
    func ShiftCallback Function that receives a string of shifted chars.

    stringStream.split(splitter) ↺

    Splits the string stream by the specified RegExp or string

    Kind: instance method of StringStream
    Chainable
    Test: test/methods/string-stream-split.js

    Param Type Description
    splitter RegExp | String What to split by

    stringStream.match(matcher) ↺

    Finds matches in the string stream and streams the match results

    Kind: instance method of StringStream
    Chainable
    Test: test/methods/string-stream-match.js

    Param Type Description
    matcher RegExp A function that will be called for every stream chunk.

    stringStream.toBufferStream() : BufferStream ↺

    Transforms the StringStream to BufferStream

    Creates a buffer stream from the given string 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 StringStream
    Chainable
    Overrides: toBufferStream
    Returns: BufferStream - The converted stream.
    Meta.noreadme:
    Test: test/methods/string-stream-tobufferstream.js

    stringStream.parse(parser) : DataStream ↺

    Parses every string to object

    The method MUST parse EVERY string into a single object, so the string stream here should already be split.

    Kind: instance method of StringStream
    Chainable
    Returns: DataStream - The parsed objects stream.
    Test: test/methods/string-stream-parse.js

    Param Type Description
    parser ParseCallback The transform function

    stringStream.toDataStream()

    Alias for parse

    Kind: instance method of StringStream

    stringStream.lines([eol]) ↺

    Splits the string stream by the specified regexp or string

    Kind: instance method of StringStream
    Chainable
    Test: test/methods/string-stream-split.js

    Param Type Default Description
    [eol] String /\r?\n/ End of line string

    stringStream.JSONParse(perLine) : DataStream ↺

    Parses each entry as JSON. Ignores empty lines

    Kind: instance method of StringStream
    Chainable
    Returns: DataStream - stream of parsed items

    Param Type Description
    perLine Boolean instructs to split per line

    stringStream.CSVParse(options) : DataStream ↺

    Parses CSV to DataString using 'papaparse' module.

    Kind: instance method of StringStream
    Chainable
    Returns: DataStream - stream of parsed items
    Test: test/methods/data-stream-separate.js

    Param Description
    options options for the papaparse.parse method.

    stringStream.append(param) ↺

    Appends given argument to all the items.

    Kind: instance method of StringStream
    Chainable
    Test: test/methods/string-stream-append.js

    Param Type Description
    param function | String the argument to append. If function passed then it will be called and resolved and the resolution will be appended.

    stringStream.prepend(param) ↺

    Prepends given argument to all the items.

    Kind: instance method of StringStream
    Chainable
    Test: test/methods/string-stream-prepend.js

    Param Type Description
    param function | String the argument to prepend. If function passed then it will be called and resolved and the resolution will be prepended.

    stringStream.exec(command, options, args)

    Executes a given sub-process with arguments and pipes the current stream into it while returning the output as another DataStream.

    Pipes the current stream into the sub-processes stdin. The data is serialized and deserialized as JSON lines by default. You can provide your own alternative methods in the ExecOptions object.

    Note: if you're piping both stderr and stdout (options.stream=3) keep in mind that chunks may get mixed up!

    Kind: instance method of StringStream
    Overrides: exec
    Test: test/methods/string-stream-exec.js

    Param Type Description
    command String command to execute
    options ExecOptions options to be passed to spawn and defining serialization.
    args String additional arguments (will overwrite to SpawnOptions args even if not given)

    stringStream.pop(bytes, func) ↺

    Shifts given length of chars from the original stream

    Works the same way as {@see DataStream.shift}, but in this case extracts the given number of characters.

    Kind: instance method of StringStream
    Chainable
    Overrides: shift
    Test: test/methods/string-stream-shift.js

    Param Type Description
    bytes Number The number of characters to shift.
    func ShiftCallback Function that receives a string of shifted chars.

    StringStream:SPLIT_LINE

    A handy split by line regex to quickly get a line-by-line stream

    Kind: static property of StringStream

    StringStream:fromString(stream, encoding) : StringStream

    Creates a StringStream and writes a specific string.

    Kind: static method of StringStream
    Returns: StringStream - new StringStream.

    Param Type Description
    stream String the string to push the your stream
    encoding String optional encoding

    StringStream:pipeline(readable, transforms) : StringStream

    Creates a pipeline of streams and returns a scramjet stream.

    Kind: static method of StringStream
    Returns: StringStream - a new StringStream instance of the resulting pipeline
    See: DataStream.pipeline

    Param Type Description
    readable Array | Iterable | AsyncGeneratorFunction | GeneratorFunction | AsyncFunction | function | String | Readable the initial readable argument that is streamable by scramjet.from
    transforms AsyncFunction | function | Transform Transform functions (as in DataStream..use) or Transform streams (any number of these as consecutive arguments)

    StringStream:from(source, options) : StringStream

    Create StringStream from anything.

    Kind: static method of StringStream
    Returns: StringStream - new StringStream.
    See

    • DataStream.from
    • module:scramjet.from
    Param Type Description
    source String | Array | Iterable | AsyncGeneratorFunction | GeneratorFunction | AsyncFunction | function | Readable argument to be turned into new stream
    options StreamOptions | Writable

    StringStream:ExecDataOptions : StringStream.ExecOptions

    Kind: static typedef of StringStream
    Extends: 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

    StringStream:ShiftCallback : function

    Kind: static typedef of StringStream

    Param Type Description
    shifted String Popped chars

    StringStream:ParseCallback : Promise

    Kind: static typedef of StringStream
    Returns: Promise - the promise should be resolved with the parsed object

    Param Type Description
    chunk String the transformed chunk

    StringStream:ExecOptions : child_process.SpawnOptions

    Kind: static typedef of StringStream
    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