Socket
Socket
Sign inDemoInstall

@xylabs/threads

Package Overview
Dependencies
Maintainers
5
Versions
77
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@xylabs/threads - npm Package Compare versions

Comparing version 3.6.5 to 3.6.6

9

dist/esm/master/implementation.node.js

@@ -38,7 +38,6 @@ "use strict";

function createTsNodeModule(scriptPath) {
const content = `
return `
require("ts-node/register/transpile-only");
require(${JSON.stringify(scriptPath)});
`;
return content;
}

@@ -55,4 +54,3 @@ function rebaseScriptPath(scriptPath, ignoreRegex) {

}
const rebasedScriptPath = callerPath ? node_path_1.default.join(node_path_1.default.dirname(callerPath), scriptPath) : scriptPath;
return rebasedScriptPath;
return callerPath ? node_path_1.default.join(node_path_1.default.dirname(callerPath), scriptPath) : scriptPath;
}

@@ -63,6 +61,5 @@ function resolveScriptPath(scriptPath, baseURL) {

};
const workerFilePath = typeof __non_webpack_require__ === 'function' ?
return typeof __non_webpack_require__ === 'function' ?
__non_webpack_require__.resolve(makeRelative(scriptPath))
: eval('require').resolve(makeRelative(rebaseScriptPath(scriptPath, /[/\\]worker_threads[/\\]/)));
return workerFilePath;
}

@@ -69,0 +66,0 @@ function initWorkerThreadsWorker() {

@@ -38,7 +38,6 @@ "use strict";

function createTsNodeModule(scriptPath) {
const content = `
return `
require("ts-node/register/transpile-only");
require(${JSON.stringify(scriptPath)});
`;
return content;
}

@@ -55,4 +54,3 @@ function rebaseScriptPath(scriptPath, ignoreRegex) {

}
const rebasedScriptPath = callerPath ? node_path_1.default.join(node_path_1.default.dirname(callerPath), scriptPath) : scriptPath;
return rebasedScriptPath;
return callerPath ? node_path_1.default.join(node_path_1.default.dirname(callerPath), scriptPath) : scriptPath;
}

@@ -63,6 +61,5 @@ function resolveScriptPath(scriptPath, baseURL) {

};
const workerFilePath = typeof __non_webpack_require__ === 'function' ?
return typeof __non_webpack_require__ === 'function' ?
__non_webpack_require__.resolve(makeRelative(scriptPath))
: eval('require').resolve(makeRelative(rebaseScriptPath(scriptPath, /[/\\]worker_threads[/\\]/)));
return workerFilePath;
}

@@ -69,0 +66,0 @@ function initWorkerThreadsWorker() {

{
"name": "@xylabs/threads",
"version": "3.6.5",
"version": "3.6.6",
"description": "Web workers & worker threads as simple as a function call",

@@ -86,5 +86,5 @@ "license": "MIT",

"dependencies": {
"@babel/types": "^7.24.9",
"@babel/types": "^7.25.2",
"callsites-3-1-0": "npm:callsites@3.1.0",
"debug": "^4.3.5",
"debug": "^4.3.6",
"is-observable-2-1-0": "npm:is-observable@2.1.0",

@@ -99,3 +99,3 @@ "observable-fns": "^0.6.1"

"@types/execa": "^2.0.0",
"@types/node": "^20.14.12",
"@types/node": "^22.0.0",
"@types/webpack": "^5.28.5",

@@ -110,4 +110,4 @@ "ava": "^6.1.3",

"raw-loader": "^4.0.2",
"rimraf": "^5.0.9",
"rollup": "^4.19.0",
"rimraf": "^4.4.1",
"rollup": "^4.19.1",
"threads-plugin": "^1.4.0",

@@ -118,3 +118,3 @@ "tiny-worker": "^2.3.0",

"typescript": "^5.5.4",
"undici-types": "^6.19.4",
"undici-types": "^6.19.5",
"wavy": "^1.0.4",

@@ -121,0 +121,0 @@ "webpack": "^5.93.0",

@@ -0,1 +1,3 @@

/* eslint-disable unicorn/no-process-exit */
/* eslint-disable sonarjs/no-identical-functions */
/* eslint-disable unicorn/prefer-logical-operator-over-ternary */

@@ -8,3 +10,2 @@ /* eslint-disable unicorn/prefer-regexp-test */

/* eslint-disable unicorn/text-encoding-identifier-case */
/* eslint-disable unicorn/no-process-exit */
/// <reference lib="dom" />

@@ -60,7 +61,6 @@

function createTsNodeModule(scriptPath: string) {
const content = `
return `
require("ts-node/register/transpile-only");
require(${JSON.stringify(scriptPath)});
`
return content
}

@@ -81,5 +81,3 @@

}
const rebasedScriptPath = callerPath ? path.join(path.dirname(callerPath), scriptPath) : scriptPath
return rebasedScriptPath
return callerPath ? path.join(path.dirname(callerPath), scriptPath) : scriptPath
}

@@ -93,8 +91,5 @@

const workerFilePath =
typeof __non_webpack_require__ === 'function' ?
return typeof __non_webpack_require__ === 'function' ?
__non_webpack_require__.resolve(makeRelative(scriptPath))
: eval('require').resolve(makeRelative(rebaseScriptPath(scriptPath, /[/\\]worker_threads[/\\]/)))
return workerFilePath
}

@@ -101,0 +96,0 @@

@@ -0,1 +1,2 @@

/* eslint-disable sonarjs/no-all-duplicated-branches */
/* eslint-disable @typescript-eslint/no-explicit-any */

@@ -2,0 +3,0 @@ /*

@@ -0,1 +1,2 @@

/* eslint-disable import/export */
/* eslint-disable unicorn/no-thenable */

@@ -2,0 +3,0 @@

@@ -0,1 +1,2 @@

/* eslint-disable sonarjs/prefer-immediate-return */
/* eslint-disable @typescript-eslint/no-explicit-any */

@@ -2,0 +3,0 @@ import { Observable, ObservableLike, SubscriptionObserver } from 'observable-fns'

@@ -0,1 +1,2 @@

/* eslint-disable sonarjs/prefer-single-boolean-return */
/* eslint-disable @typescript-eslint/no-explicit-any */

@@ -2,0 +3,0 @@ import { $transferable } from './symbols'

@@ -0,1 +1,2 @@

/* eslint-disable sonarjs/prefer-immediate-return */
/* eslint-disable @typescript-eslint/no-explicit-any */

@@ -2,0 +3,0 @@ /// <reference lib="dom" />

@@ -0,1 +1,2 @@

/* eslint-disable import/no-unresolved */
/* eslint-disable @typescript-eslint/no-explicit-any */

@@ -2,0 +3,0 @@

@@ -0,1 +1,2 @@

/* eslint-disable sonarjs/no-use-of-empty-return-value */
/* eslint-disable @typescript-eslint/no-explicit-any */

@@ -2,0 +3,0 @@

@@ -0,1 +1,2 @@

/* eslint-disable sonarjs/no-duplicate-string */
/* eslint-disable @typescript-eslint/no-explicit-any */

@@ -2,0 +3,0 @@ import test from 'ava'

@@ -11,2 +11,5 @@ /* eslint-disable @typescript-eslint/no-floating-promises */

const workerPath = './workers/hello-world'
const HELLO_WORLD = 'Hello World'
test.serial('thread pool basics work and events are emitted', async (t) => {

@@ -19,3 +22,3 @@ const events: Pool.Event[] = []

spawnCalled++
return spawn<() => string>(new Worker('./workers/hello-world'))
return spawn<() => string>(new Worker(workerPath))
}

@@ -37,3 +40,3 @@ const pool = Pool(spawnHelloWorld, 3)

const result = await helloWorld()
t.is(result, 'Hello World')
t.is(result, HELLO_WORLD)
return result

@@ -61,3 +64,3 @@ })

{
returnValue: 'Hello World',
returnValue: HELLO_WORLD,
taskID: 1,

@@ -80,3 +83,3 @@ type: Pool.EventType.taskCompleted,

const spawnHelloWorld = () => spawn(new Worker('./workers/hello-world'))
const spawnHelloWorld = () => spawn(new Worker(workerPath))
const pool = Pool(spawnHelloWorld, 2)

@@ -92,7 +95,7 @@

t.deepEqual(returned, ['Hello World', 'Hello World', 'Hello World'])
t.deepEqual(returned, [HELLO_WORLD, HELLO_WORLD, HELLO_WORLD])
})
test.serial('pool.completed() proxies errors', async (t) => {
const spawnHelloWorld = () => spawn(new Worker('./workers/hello-world'))
const spawnHelloWorld = () => spawn(new Worker(workerPath))
const pool = Pool(spawnHelloWorld, 2)

@@ -109,3 +112,3 @@

test.serial('pool.completed(true) works', async (t) => {
const spawnHelloWorld = () => spawn(new Worker('./workers/hello-world'))
const spawnHelloWorld = () => spawn(new Worker(workerPath))
const pool = Pool(spawnHelloWorld, 2)

@@ -118,5 +121,6 @@

test.serial('pool.settled() does not reject on task failure', async (t) => {
// eslint-disable-next-line sonarjs/no-unused-collection
const returned: any[] = []
const spawnHelloWorld = () => spawn(new Worker('./workers/hello-world'))
const spawnHelloWorld = () => spawn(new Worker(workerPath))
const pool = Pool(spawnHelloWorld, 2)

@@ -140,3 +144,3 @@

test.serial('pool.settled(true) works', async (t) => {
const spawnHelloWorld = () => spawn(new Worker('./workers/hello-world'))
const spawnHelloWorld = () => spawn(new Worker(workerPath))
const pool = Pool(spawnHelloWorld, 2)

@@ -150,3 +154,3 @@

const events: Pool.Event[] = []
const spawnHelloWorld = () => spawn(new Worker('./workers/hello-world'))
const spawnHelloWorld = () => spawn(new Worker(workerPath))
const pool = Pool(spawnHelloWorld, 1)

@@ -153,0 +157,0 @@

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