Package Exports
- thread-stream
This package does not declare an exports field, so the exports above have been automatically detected and optimized by JSPM instead. If any package subpath is missing, it is recommended to post an issue to the original package (thread-stream) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.
Readme
thread-stream
A streaming way to send data to a Node.js Worker Thread.
install
npm i thread-streamUsage
'use strict'
const ThreadStream = require('thread-stream')
const { join } = require('path')
const stream = new ThreadStream({
filename: join(__dirname, 'worker.js'),
workerData: { dest }
})
stream.write('hello')
stream.flush(function () {
stream.write(' ')
stream.write('world')
stream.flushSync()
stream.end()
})In worker.js:
'use strict'
const fs = require('fs')
const { once } = require('events')
async function run (opts) {
const stream = fs.createWriteStream(opts.dest)
await once(stream, 'open')
return stream
}
module.exports = runLicense
MIT