stream-util2

1.3.1 • Public • Published

stream-util2

npm version

Various stream utilities.

Installation

npm install stream-util2

API

transform(transform, [flush])

Returns a transform stream in object mode.

  • transform implements _transform. Arguments: chunk, callback.
  • flush implements _flush.

readable(read)

Returns a readable stream in object mode.

writable(write)

Returns a writable stream in object mode.

  • write implements _write. Arguments: chunk, callback.

buffer()

Returns a transform stream that buffers chunks of <Buffer> type and emits concatenated buffer down the stream.

toString()

Returns a transform stream that calls chunk.toString() for each chunk.

consoleLog()

Returns a transform stream that calls console.log(chunk) for each chunk.

readArray(array)

Returns a readable stream that reads the array and emits each item down the stream.

pushArray(array)

Returns a transform stream that pushes each chunk to array.

bufferArray()

Returns a transform stream that buffers chunks to an array and emits it down the stream.

writeVoid()

Returns a writable stream that does nothing.

readFunction(options, fn)

Returns a readable stream that generates data from periodic function fn.

Options:

  • T - function period in milliseconds. Default is 1000.

fn arguments:

  • dt - delta time since beginning of current period.
  • T - period.

writePromise([options])

Returns instance of PromiseWriteStream, a writable stream that conforms to Promise. It buffers data and resolves the promise right before emitting the finish event.

Options:

PromiseWriteStream

PromiseWriteStream is a writable stream that conforms to Promise. Internal buffer and promise can be retrieved using writablePromise.buffer and writablePromise.promise, respectively.

License

ISC

Readme

Keywords

Package Sidebar

Install

npm i stream-util2

Weekly Downloads

3

Version

1.3.1

License

ISC

Unpacked Size

7.19 kB

Total Files

15

Last publish

Collaborators

  • monai