Socket
Socket
Sign inDemoInstall

node-worker-threads-pool

Package Overview
Dependencies
0
Maintainers
1
Versions
31
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

Comparing version 1.5.0 to 1.5.1

10

dist/dynamicPool.js

@@ -13,11 +13,3 @@ "use strict";

function __awaiter(thisArg, _arguments, P, generator) {
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
return new (P || (P = Promise))(function (resolve, reject) {
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
step((generator = generator.apply(thisArg, _arguments || [])).next());
});
}
${utils_1.WORKER_RUNTIME_HELPER_CODE}

@@ -24,0 +16,0 @@ process.once("unhandledRejection", (err) => {

@@ -13,11 +13,3 @@ "use strict";

function __awaiter(thisArg, _arguments, P, generator) {
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
return new (P || (P = Promise))(function (resolve, reject) {
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
step((generator = generator.apply(thisArg, _arguments || [])).next());
});
}
${utils_1.WORKER_RUNTIME_HELPER_CODE}

@@ -91,8 +83,2 @@ this.workerData = workerData;

}
this.exec = ((param) => {
if (typeof param === 'function') {
throw new TypeError('"param" can not be a function!');
}
return this.runTask(param, { timeout: 0 });
});
}

@@ -99,0 +85,0 @@ /**

1

dist/utils.d.ts
export declare function createFunctionString(fn: Function): string;
export declare const WORKER_RUNTIME_HELPER_CODE = "\n function __awaiter(thisArg, _arguments, P, generator) {\n function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }\n return new (P || (P = Promise))(function (resolve, reject) {\n function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }\n function rejected(value) { try { step(generator[\"throw\"](value)); } catch (e) { reject(e); } }\n function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }\n step((generator = generator.apply(thisArg, _arguments || [])).next());\n });\n }\n";
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.createFunctionString = void 0;
const es6FuncRegexp = /^task[^]*([^]*)[^]*{[^]*}$/;
exports.WORKER_RUNTIME_HELPER_CODE = exports.createFunctionString = void 0;
const ES6_FUNC_REGEXP = /^task[^]*([^]*)[^]*{[^]*}$/;
function createFunctionString(fn) {
const strFn = Function.prototype.toString.call(fn);
let expression = '';
if (es6FuncRegexp.test(strFn)) {
if (ES6_FUNC_REGEXP.test(strFn)) {
// ES6 style in-object function.

@@ -19,1 +19,12 @@ expression = 'function ' + strFn;

exports.createFunctionString = createFunctionString;
exports.WORKER_RUNTIME_HELPER_CODE = `
function __awaiter(thisArg, _arguments, P, generator) {
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
return new (P || (P = Promise))(function (resolve, reject) {
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
step((generator = generator.apply(thisArg, _arguments || [])).next());
});
}
`;
{
"name": "node-worker-threads-pool",
"version": "1.5.0",
"version": "1.5.1",
"description": "Simple worker threads pool using Node's worker_threads module. Compatible with ES6+ Promise, Async/Await.",

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

@@ -85,3 +85,3 @@ # node-worker-threads-pool

- `size` `<number>` Number of workers in this pool.
- `task` `<string | function>` Static task to do. It can be a absolute path of worker file ([usage here](#example-with-worker-file)) or a function. **⚠️Notice: If task is a function, you can not use closure in it! If you do want to use external data in the function, use workerData to pass some [cloneable data].**
- `task` `<string | function>` Static task to do. It can be a absolute path of worker file ([usage here](#example-with-worker-file)) or a function. **⚠️Notice: If task is a function, you can NOT access variables defined outside the task function! If you do want to use external data, use workerData to pass some [cloneable data].**
- `workerData` `<any>` [Cloneable data][cloneable data] you want to access in task function. ([usage here](#access-workerdata-in-task-function))

@@ -243,3 +243,3 @@ - `shareEnv` `<boolean>` Set `true` to enable [SHARE_ENV] for all threads in pool.

- `opt`
- `task` `<function>` Function as a task to do. **⚠️Notice: You can not use closure in task function!**
- `task` `<function>` Function as a task to do. **⚠️Notice: You can NOT access variables defined outside the task function!**
- `timeout` `<number>` Timeout in milisecond for limiting the execution time. When timeout, the function will throw a `TimeoutError`, use `isTimeoutError` function to detect it.

@@ -246,0 +246,0 @@ - Returns: `<Promise>`

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