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

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

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

    Example:

    StringStream.fromString()

    Kind: inner class
    Extends: DataStream
    Test: test/methods/string-stream-constructor.js

    new StringStream(encoding)

    Constructs the stream with the given encoding

    Returns: StringStream - the created data stream

    Param Type Description
    encoding String the encoding to use

    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
    Test: test/methods/string-stream-shift.js

    Param Type Description
    bytes Number The number of characters to shift.
    func ShiftStringCallback 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
    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 StringStream#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 Default Description
    [perLine] Boolean true 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 Type Default Description
    [options] Object {} 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])

    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
    Test: test/methods/string-stream-exec.js

    Param Type Default 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: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 DataStreamOptions | Writable