🚀 Big News: Socket Acquires Coana to Bring Reachability Analysis to Every Appsec Team.Learn more
Socket
Book a DemoInstallSign in
Socket

thread-stream

Package Overview
Dependencies
Maintainers
4
Versions
43
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

thread-stream - npm Package Compare versions

Comparing version

to
0.8.0

test/port.js

1

index.js

@@ -19,2 +19,3 @@ 'use strict'

const worker = new Worker(toExecute, {
...opts.workerOpts,
workerData: {

@@ -21,0 +22,0 @@ filename: filename.indexOf('file://') === 0

2

package.json
{
"name": "thread-stream",
"version": "0.7.2",
"version": "0.8.0",
"description": "A streaming way to send data to a Node.js Worker Thread",

@@ -5,0 +5,0 @@ "main": "index.js",

@@ -22,3 +22,4 @@ # thread-stream

workerData: { dest },
sync: false // default
workerOpts: {}, // Other options to be passed to Worker
sync: false, // default
})

@@ -25,0 +26,0 @@

@@ -8,2 +8,4 @@ 'use strict'

const ThreadStream = require('..')
const { MessageChannel } = require('worker_threads')
const { once } = require('events')

@@ -288,1 +290,25 @@ test('base sync=true', function (t) {

})
test('pass down MessagePorts', async function (t) {
t.plan(3)
const { port1, port2 } = new MessageChannel()
const stream = new ThreadStream({
filename: join(__dirname, 'port.js'),
workerData: { port: port1 },
workerOpts: {
transferList: [port1]
},
sync: false
})
t.teardown(() => {
stream.end()
})
t.ok(stream.write('hello world\n'))
t.ok(stream.write('something else\n'))
const [strings] = await once(port2, 'message')
t.equal(strings, 'hello world\nsomething else\n')
})