package
Wrap a readable/writable/duplex/transform stream to a thunk function.
npm install thunk-streamGitHub-flavored package documentation.
Across all versions.
Download trend unavailable.
Runtime metadata.
Tagged topics.
Estimated unpacked size across 2 packages.
40.5 kB
Includes dependencies.
Wrap a readable/writable/duplex/transform stream to a thunk.
const thunkStream = require('thunk-stream')
const stream = require('stream')
const fs = require('fs')
const readableStream = fs.createReadStream('index.js')
const passStream = new stream.PassThrough()
thunkStream(readableStream)(function (error) {
if (error) console.error('error', error)
else console.log('read file end.')
})
thunkStream(passStream)(function (error) {
npm install thunk-streamconst thunkStream = require('thunk-stream')Return a thunk function.
Required, Type: stream, readable/writable/duplex/transform stream.
Optional, Type: String or Array
Appoint one or more event types to delegate the stream end. In built end event types: ['end', 'finish', 'close', 'error'].
Optional, Type: Boolean
If true, ignore error event for stream end.
Optional, Type: Boolean
If true, ignore end event for stream end.
Optional, Type: Boolean
If true, ignore finish event for stream end.
Optional, Type: Boolean
If true, ignore close event for stream end.
Optional, Type: Boolean
If true, ignore eventType event for stream end.
After thunk is called, clearListeners is added that can remove all listeners added to stream by thunkStream. if listeners has been removed already, it return false, else return true.