Socket
Socket
Sign inDemoInstall

thread-stream

Package Overview
Dependencies
1
Maintainers
4
Versions
40
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

Comparing version 2.1.0 to 2.2.0

test/context.test.js

9

index.js
'use strict'
const { version } = require('./package.json')
const { EventEmitter } = require('events')

@@ -32,2 +33,3 @@ const { Worker } = require('worker_threads')

register () {}
unregister () {}

@@ -59,3 +61,8 @@ }

stateBuf: stream[kImpl].stateBuf,
workerData
workerData: {
$context: {
threadStreamVersion: version
},
...workerData
}
}

@@ -62,0 +69,0 @@ })

16

lib/worker.js

@@ -20,3 +20,3 @@ 'use strict'

async function start () {
let fn
let worker
try {

@@ -32,5 +32,5 @@ if (filename.endsWith('.ts') || filename.endsWith('.cts')) {

// Remove extra forwardslash on Windows
fn = realRequire(decodeURIComponent(filename.replace(process.platform === 'win32' ? 'file:///' : 'file://', '')))
worker = realRequire(decodeURIComponent(filename.replace(process.platform === 'win32' ? 'file:///' : 'file://', '')))
} else {
fn = (await realImport(filename))
worker = (await realImport(filename))
}

@@ -48,6 +48,6 @@ } catch (error) {

filename.startsWith('file://')) {
fn = realRequire(decodeURIComponent(filename.replace('file://', '')))
worker = realRequire(decodeURIComponent(filename.replace('file://', '')))
} else if (error.code === undefined) {
// When bundled with pkg, an undefined error is thrown when called with realImport
fn = realRequire(decodeURIComponent(filename.replace(process.platform === 'win32' ? 'file:///' : 'file://', '')))
worker = realRequire(decodeURIComponent(filename.replace(process.platform === 'win32' ? 'file:///' : 'file://', '')))
} else {

@@ -61,6 +61,6 @@ throw error

// See https://github.com/pinojs/pino/issues/1243#issuecomment-982774762
if (typeof fn === 'object') fn = fn.default
if (typeof fn === 'object') fn = fn.default
if (typeof worker === 'object') worker = worker.default
if (typeof worker === 'object') worker = worker.default
destination = await fn(workerData.workerData)
destination = await worker(workerData.workerData)

@@ -67,0 +67,0 @@ destination.on('error', function (err) {

{
"name": "thread-stream",
"version": "2.1.0",
"version": "2.2.0",
"description": "A streaming way to send data to a Node.js Worker Thread",

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

@@ -6,4 +6,5 @@ 'use strict'

const ThreadStream = require('..')
require('why-is-node-running')
test('event propagate', function (t) {
test('event propagate', (t) => {
const stream = new ThreadStream({

@@ -14,2 +15,3 @@ filename: join(__dirname, 'emit-event.js'),

})
t.on('end', () => stream.end())
stream.on('socketError', function (a, b, c, n, error) {

@@ -24,3 +26,2 @@ t.same(a, 'list')

stream.write('hello')
stream.end()
})

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc