1.3.1 • Published 2 years ago

stream-util2 v1.3.1

Weekly downloads
2
License
ISC
Repository
github
Last release
2 years ago

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

1.3.1

2 years ago

1.3.0

2 years ago

1.2.0

4 years ago

1.1.0

4 years ago

1.0.0

7 years ago

0.0.3

9 years ago

0.0.2

9 years ago

0.0.1

9 years ago