Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
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 0.11.0 to 0.11.1

.github/workflows/package-manager-ci.yml

20

lib/worker.js

@@ -18,3 +18,21 @@ 'use strict'

async function start () {
const fn = (await import(workerData.filename)).default
let fn
try {
fn = (await import(workerData.filename)).default
} catch (error) {
// A yarn user that tries to start a ThreadStream for an external module
// provides a filename pointing to a zip file.
// eg. require.resolve('pino-elasticsearch') // returns /foo/pino-elasticsearch-npm-6.1.0-0c03079478-6915435172.zip/bar.js
// The `import` will fail to try to load it.
// This catch block executes the `require` fallback to load the module correctly.
// In fact, yarn modifies the `require` function to manage the zipped path.
// More details at https://github.com/pinojs/pino/pull/1113
// The error codes may change based on the node.js version (ENOTDIR > 12, ERR_MODULE_NOT_FOUND <= 12 )
if ((error.code === 'ENOTDIR' || error.code === 'ERR_MODULE_NOT_FOUND') &&
workerData.filename.startsWith('file://')) {
fn = require(workerData.filename.replace('file://', ''))
} else {
throw error
}
}
destination = await fn(workerData.workerData)

@@ -21,0 +39,0 @@

3

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

@@ -17,2 +17,3 @@ "main": "index.js",

"test:ci": "standard && tap \"test/**/*.test.*js\" --no-check-coverage --coverage-report=lcovonly",
"test:yarn": "tap \"test/**/*.test.js\" --no-check-coverage",
"prepare": "husky install"

@@ -19,0 +20,0 @@ },

@@ -67,4 +67,26 @@ # thread-stream

### External modules
You may use this module within compatible external modules, that exports the `worker.js` interface.
```js
const ThreadStream = require('thread-stream')
const modulePath = require.resolve('pino-elasticsearch')
const stream = new ThreadStream({
filename: modulePath,
workerData: { node: 'http://localhost:9200' }
})
stream.write('log to elasticsearch!')
stream.flushSync()
stream.end()
```
This module works with `yarn` in PnP (plug'n play) mode too!
## License
MIT

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

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

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc