Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

piscina

Package Overview
Dependencies
Maintainers
3
Versions
33
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

piscina - npm Package Compare versions

Comparing version 1.6.3 to 2.0.0

.vscode/launch.json

25

dist/package.json
{
"name": "piscina",
"version": "1.6.3",
"version": "2.0.0",
"description": "A fast, efficient Node.js Worker Thread Pool implementation",

@@ -35,17 +35,17 @@ "main": "./dist/src/index.js",

"devDependencies": {
"@types/node": "^14.0.19",
"@typescript-eslint/eslint-plugin": "^3.6.0",
"@typescript-eslint/parser": "^3.6.0",
"@types/node": "^14.14.6",
"@typescript-eslint/eslint-plugin": "^4.6.1",
"@typescript-eslint/parser": "^4.6.1",
"abort-controller": "^3.0.0",
"concat-stream": "^2.0.0",
"gen-esm-wrapper": "^1.0.6",
"snazzy": "^8.0.0",
"standardx": "^5.0.0",
"tap": "^14.10.7",
"typescript": "^3.9.6"
"gen-esm-wrapper": "^1.1.0",
"snazzy": "^9.0.0",
"standardx": "^6.0.0",
"tap": "^14.10.8",
"typescript": "^4.0.5"
},
"dependencies": {
"eventemitter-asyncresource": "^1.0.0",
"hdr-histogram-js": "^1.2.0",
"hdr-histogram-percentiles-obj": "^2.0.1"
"hdr-histogram-js": "^2.0.1",
"hdr-histogram-percentiles-obj": "^3.0.0"
},

@@ -62,2 +62,5 @@ "optionalDependencies": {

"no-unused-vars": "off",
"no-use-before-define": "off",
"no-unreachable-loop": "off",
"no-dupe-class-members": "off",
"@typescript-eslint/no-unused-vars": "error"

@@ -64,0 +67,0 @@ },

@@ -24,3 +24,2 @@ /// <reference types="node" />

} ? T : never;
declare type TransferListItem = TransferList extends (infer T)[] ? T : never;
interface Options {

@@ -41,2 +40,3 @@ filename?: string | null;

niceIncrement?: number;
trackUnmanagedFds?: boolean;
}

@@ -57,6 +57,10 @@ interface FilledOptions extends Options {

} ? T : never;
declare type TransferListItem = TransferList extends (infer T)[] ? T : never;
declare class Piscina extends EventEmitterAsyncResource {
#private;
constructor(options?: Options);
runTask(task: any, transferList?: TransferList | string | AbortSignalAny, filename?: string | AbortSignalAny, abortSignal?: AbortSignalAny): Promise<any>;
runTask(task: any, transferList?: TransferList, filename?: string, abortSignal?: AbortSignalAny): Promise<any>;
runTask(task: any, transferList?: TransferList, filename?: AbortSignalAny, abortSignal?: undefined): Promise<any>;
runTask(task: any, transferList?: string, filename?: AbortSignalAny, abortSignal?: undefined): Promise<any>;
runTask(task: any, transferList?: AbortSignalAny, filename?: undefined, abortSignal?: undefined): Promise<any>;
destroy(): Promise<void>;

@@ -75,3 +79,3 @@ get options(): FilledOptions;

static get Piscina(): typeof Piscina;
static move(val: Transferable | TransferListItem | ArrayBufferView): ArrayBufferView | Transferable;
static move(val: Transferable | TransferListItem | ArrayBufferView | ArrayBuffer | MessagePort): ArrayBuffer | ArrayBufferView | MessagePort | Transferable;
static get transferableSymbol(): symbol;

@@ -78,0 +82,0 @@ static get valueSymbol(): symbol;

@@ -82,3 +82,4 @@ "use strict";

taskQueue: new ArrayTaskQueue(),
niceIncrement: 0
niceIncrement: 0,
trackUnmanagedFds: true
};

@@ -104,3 +105,4 @@ class DirectlyTransferable {

return filename.startsWith('file:')
? url_1.fileURLToPath(new url_1.URL(filename)) : filename;
? url_1.fileURLToPath(new url_1.URL(filename))
: filename;
}

@@ -233,3 +235,3 @@ // Extend AsyncResource so that async relations between posting a task and

super();
this.idleTimeout = null;
this.idleTimeout = null; // eslint-disable-line no-undef
this.lastSeenResponseCount = 0;

@@ -377,3 +379,4 @@ this.worker = worker;

resourceLimits: this.options.resourceLimits,
workerData: this.options.workerData
workerData: this.options.workerData,
trackUnmanagedFds: this.options.trackUnmanagedFds
});

@@ -685,2 +688,6 @@ const { port1, port2 } = new worker_threads_1.MessageChannel();

}
if (options.trackUnmanagedFds !== undefined &&
typeof options.trackUnmanagedFds !== 'boolean') {
throw new TypeError('options.trackUnmanagedFds must be a boolean value');
}
__classPrivateFieldSet(this, _pool, new ThreadPool(this, options));

@@ -746,4 +753,4 @@ }

const capacity = this.duration * __classPrivateFieldGet(this, _pool).options.maxThreads;
const totalMeanRuntime = __classPrivateFieldGet(this, _pool).runTime.getMean() *
__classPrivateFieldGet(this, _pool).runTime.getTotalCount();
const totalMeanRuntime = __classPrivateFieldGet(this, _pool).runTime.mean *
__classPrivateFieldGet(this, _pool).runTime.totalCount;
// We calculate the appoximate pool utilization by multiplying

@@ -750,0 +757,0 @@ // the mean run time of all tasks by the number of runtime

@@ -17,3 +17,3 @@ "use strict";

var result = {};
if (mod != null) for (var k in mod) if (k !== "default" && Object.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
__setModuleDefault(result, mod);

@@ -20,0 +20,0 @@ return result;

{
"name": "piscina",
"version": "1.6.3",
"version": "2.0.0",
"description": "A fast, efficient Node.js Worker Thread Pool implementation",

@@ -35,17 +35,17 @@ "main": "./dist/src/index.js",

"devDependencies": {
"@types/node": "^14.0.19",
"@typescript-eslint/eslint-plugin": "^3.6.0",
"@typescript-eslint/parser": "^3.6.0",
"@types/node": "^14.14.6",
"@typescript-eslint/eslint-plugin": "^4.6.1",
"@typescript-eslint/parser": "^4.6.1",
"abort-controller": "^3.0.0",
"concat-stream": "^2.0.0",
"gen-esm-wrapper": "^1.0.6",
"snazzy": "^8.0.0",
"standardx": "^5.0.0",
"tap": "^14.10.7",
"typescript": "^3.9.6"
"gen-esm-wrapper": "^1.1.0",
"snazzy": "^9.0.0",
"standardx": "^6.0.0",
"tap": "^14.10.8",
"typescript": "^4.0.5"
},
"dependencies": {
"eventemitter-asyncresource": "^1.0.0",
"hdr-histogram-js": "^1.2.0",
"hdr-histogram-percentiles-obj": "^2.0.1"
"hdr-histogram-js": "^2.0.1",
"hdr-histogram-percentiles-obj": "^3.0.0"
},

@@ -62,2 +62,5 @@ "optionalDependencies": {

"no-unused-vars": "off",
"no-use-before-define": "off",
"no-unreachable-loop": "off",
"no-dupe-class-members": "off",
"@typescript-eslint/no-unused-vars": "error"

@@ -64,0 +67,0 @@ },

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

![Piscina Logo](https://avatars1.githubusercontent.com/u/65627548?s=200&v=4)
# piscina - the node.js worker pool

@@ -117,2 +119,5 @@

(In Node.js 15.0.0 or higher, there is a new built-in `AbortController`
implementation that can be used here as well.)
Alternatively, any `EventEmitter` that emits an `'abort'` event

@@ -263,2 +268,4 @@ may be used as an abort controller:

for generated code.
* `stackSizeMb` : (`number`) The default maximum stack size for the thread.
Small values may lead to unusable Worker instances. Default: 4
* `env`: (`object`) If set, specifies the initial value of `process.env` inside

@@ -283,2 +290,7 @@ the worker threads. See [Node.js new Worker options][] for details.

See [`nice(2)`][] for more details.
* `trackUnmanagedFds`: (`boolean`) An optional setting that, when `true`, will
cause Workers to track file descriptors managed using `fs.open()` and
`fs.close()`, and will close them automatically when the Worker exits.
Defaults to `true`. (This option is only supported on Node.js 12.19+ and
all Node.js versions higher than 14.6.0).

@@ -529,3 +541,3 @@ Use caution when setting resource limits. Setting limits that are too low may

get [valueSymbol]() {
return { a: { b: this.b }, c: this.c };
return { a: { b: this.a.b }, c: this.c };
}

@@ -532,0 +544,0 @@ };

@@ -79,4 +79,2 @@ import { Worker, MessageChannel, MessagePort, receiveMessageOnPort } from 'worker_threads';

type TransferListItem = TransferList extends (infer T)[] ? T : never;
class ArrayTaskQueue implements TaskQueue {

@@ -116,3 +114,4 @@ tasks : Task[] = [];

taskQueue? : TaskQueue,
niceIncrement? : number
niceIncrement? : number,
trackUnmanagedFds? : boolean,
}

@@ -141,3 +140,4 @@

taskQueue: new ArrayTaskQueue(),
niceIncrement: 0
niceIncrement: 0,
trackUnmanagedFds: true
};

@@ -174,6 +174,8 @@

type TransferList = MessagePort extends { postMessage(value : any, transferList : infer T) : any; } ? T : never;
type TransferListItem = TransferList extends (infer T)[] ? T : never;
function maybeFileURLToPath (filename : string) : string {
return filename.startsWith('file:')
? fileURLToPath(new URL(filename)) : filename;
? fileURLToPath(new URL(filename))
: filename;
}

@@ -350,3 +352,3 @@

taskInfos : Map<number, TaskInfo>;
idleTimeout : NodeJS.Timeout | null = null;
idleTimeout : NodeJS.Timeout | null = null; // eslint-disable-line no-undef
port : MessagePort;

@@ -530,3 +532,4 @@ sharedBuffer : Int32Array;

resourceLimits: this.options.resourceLimits,
workerData: this.options.workerData
workerData: this.options.workerData,
trackUnmanagedFds: this.options.trackUnmanagedFds
});

@@ -881,2 +884,6 @@

}
if (options.trackUnmanagedFds !== undefined &&
typeof options.trackUnmanagedFds !== 'boolean') {
throw new TypeError('options.trackUnmanagedFds must be a boolean value');
}

@@ -886,3 +893,8 @@ this.#pool = new ThreadPool(this, options);

runTask (task : any, transferList? : TransferList | string | AbortSignalAny, filename? : string | AbortSignalAny, abortSignal? : AbortSignalAny) {
runTask (task : any, transferList? : TransferList, filename? : string, abortSignal? : AbortSignalAny) : Promise<any>;
runTask (task : any, transferList? : TransferList, filename? : AbortSignalAny, abortSignal? : undefined) : Promise<any>;
runTask (task : any, transferList? : string, filename? : AbortSignalAny, abortSignal? : undefined) : Promise<any>;
runTask (task : any, transferList? : AbortSignalAny, filename? : undefined, abortSignal? : undefined) : Promise<any>;
runTask (task : any, transferList? : any, filename? : any, abortSignal? : any) {
// If transferList is a string or AbortSignal, shift it.

@@ -956,4 +968,4 @@ if ((typeof transferList === 'object' && !Array.isArray(transferList)) ||

const capacity = this.duration * this.#pool.options.maxThreads;
const totalMeanRuntime = this.#pool.runTime.getMean() *
this.#pool.runTime.getTotalCount();
const totalMeanRuntime = this.#pool.runTime.mean *
this.#pool.runTime.totalCount;

@@ -993,3 +1005,3 @@ // We calculate the appoximate pool utilization by multiplying

static move (val : Transferable | TransferListItem | ArrayBufferView) {
static move (val : Transferable | TransferListItem | ArrayBufferView | ArrayBuffer | MessagePort) {
if (val != null && typeof val === 'object' && typeof val !== 'function') {

@@ -996,0 +1008,0 @@ if (!isTransferable(val)) {

@@ -114,1 +114,11 @@ import Piscina from '..';

});
test('trackUnmanagedFds must be a boolean', async ({ throws }) => {
throws(() => new Piscina(({
trackUnmanagedFds: -1
}) as any), /options.trackUnmanagedFds must be a boolean/);
throws(() => new Piscina(({
trackUnmanagedFds: 'string'
}) as any), /options.trackUnmanagedFds must be a boolean/);
});

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