Socket
Socket
Sign inDemoInstall

worktank

Package Overview
Dependencies
2
Maintainers
1
Versions
21
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

Comparing version 2.5.2 to 2.6.0

1

dist/index.d.ts

@@ -20,2 +20,3 @@ import type { Methods, MethodsNames, MethodsProxied, MethodArguments, MethodReturn, Options } from './types';

private _getWorkerReady;
private _getWorkersWarm;
exec<U extends MethodsNames<T>>(method: U, args: MethodArguments<T, U>): Promise<Awaited<MethodReturn<T, U>>>;

@@ -22,0 +23,0 @@ proxy(): MethodsProxied<T>;

@@ -18,2 +18,5 @@ /* IMPORT */

this.workersReady = new Set();
if (options.warmup) {
this._getWorkersWarm();
}
}

@@ -77,2 +80,9 @@ /* HELPERS */

}
_getWorkersWarm() {
for (let i = 0, l = this.size; i < l; i++) {
const name = this._getWorkerName();
const worker = new Worker(this.methods, name);
this.workersReady.add(worker);
}
}
/* API */

@@ -79,0 +89,0 @@ exec(method, args) {

@@ -41,2 +41,3 @@ type FN = (...args: any[]) => any;

timeout?: number;
warmup?: boolean;
autoterminate?: number;

@@ -43,0 +44,0 @@ methods: T | URL | string;

2

package.json

@@ -5,3 +5,3 @@ {

"description": "A simple isomorphic library for executing functions inside WebWorkers or Node Threads pools.",
"version": "2.5.2",
"version": "2.6.0",
"type": "module",

@@ -8,0 +8,0 @@ "main": "dist/index.js",

@@ -37,2 +37,3 @@ # WorkTank

timeout: 10000, // The maximum number of milliseconds to wait for the result from the worker, if exceeded the worker is terminated and the execution promise rejects
warmup: true, // Pre-spawn all the workers, so that they could be closer to being ready when needed
autoterminate: 60000, // The interval of milliseconds at which to check if the pool can be automatically terminated, to free up resources, workers will be spawned up again if needed

@@ -39,0 +40,0 @@ methods: { // An object mapping function names to functions objects to serialize and deserialize into each worker thread, only functions that don't depend on their closure can be serialized

@@ -41,2 +41,6 @@

if ( options.warmup ) {
this._getWorkersWarm ();
}
}

@@ -128,3 +132,2 @@

const name = this._getWorkerName ();
const worker = new Worker<T> ( this.methods, name );

@@ -138,2 +141,15 @@

private _getWorkersWarm (): void {
for ( let i = 0, l = this.size; i < l; i++ ) {
const name = this._getWorkerName ();
const worker = new Worker<T> ( this.methods, name );
this.workersReady.add ( worker );
}
}
/* API */

@@ -140,0 +156,0 @@

@@ -64,2 +64,3 @@

timeout?: number,
warmup?: boolean,
autoterminate?: number,

@@ -66,0 +67,0 @@ methods: T | URL | string

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