jest-worker
Advanced tools
Comparing version 28.1.3 to 29.0.0-alpha.0
@@ -31,4 +31,2 @@ 'use strict'; | ||
constructor(_numOfWorkers, _callback, options = {}) { | ||
var _options$workerSchedu, _options$taskQueue; | ||
this._numOfWorkers = _numOfWorkers; | ||
@@ -38,11 +36,4 @@ this._callback = _callback; | ||
this._workerSchedulingPolicy = | ||
(_options$workerSchedu = options.workerSchedulingPolicy) !== null && | ||
_options$workerSchedu !== void 0 | ||
? _options$workerSchedu | ||
: 'round-robin'; | ||
this._taskQueue = | ||
(_options$taskQueue = options.taskQueue) !== null && | ||
_options$taskQueue !== void 0 | ||
? _options$taskQueue | ||
: new _FifoQueue.default(); | ||
options.workerSchedulingPolicy ?? 'round-robin'; | ||
this._taskQueue = options.taskQueue ?? new _FifoQueue.default(); | ||
} | ||
@@ -49,0 +40,0 @@ |
@@ -47,20 +47,5 @@ 'use strict'; | ||
dequeue(workerId) { | ||
var _this$_workerQueues$w, _workerTop$previousSh, _workerTop$previousSh2; | ||
const workerTop = | ||
(_this$_workerQueues$w = this._workerQueues[workerId]) === null || | ||
_this$_workerQueues$w === void 0 | ||
? void 0 | ||
: _this$_workerQueues$w.peek(); | ||
const workerTop = this._workerQueues[workerId]?.peek(); | ||
const sharedTaskIsProcessed = | ||
(_workerTop$previousSh = | ||
workerTop === null || workerTop === void 0 | ||
? void 0 | ||
: (_workerTop$previousSh2 = workerTop.previousSharedTask) === null || | ||
_workerTop$previousSh2 === void 0 | ||
? void 0 | ||
: _workerTop$previousSh2.request[1]) !== null && | ||
_workerTop$previousSh !== void 0 | ||
? _workerTop$previousSh | ||
: true; // Process the top task from the shared queue if | ||
workerTop?.previousSharedTask?.request[1] ?? true; // Process the top task from the shared queue if | ||
// - there's no task in the worker specific queue or | ||
@@ -71,17 +56,3 @@ // - if the non-worker-specific task after which this worker specific task | ||
if (workerTop != null && sharedTaskIsProcessed) { | ||
var _this$_workerQueues$w2, | ||
_this$_workerQueues$w3, | ||
_this$_workerQueues$w4; | ||
return (_this$_workerQueues$w2 = | ||
(_this$_workerQueues$w3 = this._workerQueues[workerId]) === null || | ||
_this$_workerQueues$w3 === void 0 | ||
? void 0 | ||
: (_this$_workerQueues$w4 = _this$_workerQueues$w3.dequeue()) === | ||
null || _this$_workerQueues$w4 === void 0 | ||
? void 0 | ||
: _this$_workerQueues$w4.task) !== null && | ||
_this$_workerQueues$w2 !== void 0 | ||
? _this$_workerQueues$w2 | ||
: null; | ||
return this._workerQueues[workerId]?.dequeue()?.task ?? null; | ||
} | ||
@@ -133,22 +104,8 @@ | ||
peek() { | ||
var _this$_head$value, _this$_head; | ||
return (_this$_head$value = | ||
(_this$_head = this._head) === null || _this$_head === void 0 | ||
? void 0 | ||
: _this$_head.value) !== null && _this$_head$value !== void 0 | ||
? _this$_head$value | ||
: null; | ||
return this._head?.value ?? null; | ||
} | ||
peekLast() { | ||
var _this$_last$value, _this$_last; | ||
return (_this$_last$value = | ||
(_this$_last = this._last) === null || _this$_last === void 0 | ||
? void 0 | ||
: _this$_last.value) !== null && _this$_last$value !== void 0 | ||
? _this$_last$value | ||
: null; | ||
return this._last?.value ?? null; | ||
} | ||
} |
@@ -116,9 +116,2 @@ 'use strict'; | ||
constructor(workerPath, options) { | ||
var _this$_options$enable, | ||
_this$_options$forkOp, | ||
_this$_options$maxRet, | ||
_this$_options$numWor, | ||
_this$_options$resour, | ||
_this$_options$setupA; | ||
this._options = {...options}; | ||
@@ -132,32 +125,9 @@ this._ending = false; | ||
const workerPoolOptions = { | ||
enableWorkerThreads: | ||
(_this$_options$enable = this._options.enableWorkerThreads) !== null && | ||
_this$_options$enable !== void 0 | ||
? _this$_options$enable | ||
: false, | ||
forkOptions: | ||
(_this$_options$forkOp = this._options.forkOptions) !== null && | ||
_this$_options$forkOp !== void 0 | ||
? _this$_options$forkOp | ||
: {}, | ||
maxRetries: | ||
(_this$_options$maxRet = this._options.maxRetries) !== null && | ||
_this$_options$maxRet !== void 0 | ||
? _this$_options$maxRet | ||
: 3, | ||
enableWorkerThreads: this._options.enableWorkerThreads ?? false, | ||
forkOptions: this._options.forkOptions ?? {}, | ||
maxRetries: this._options.maxRetries ?? 3, | ||
numWorkers: | ||
(_this$_options$numWor = this._options.numWorkers) !== null && | ||
_this$_options$numWor !== void 0 | ||
? _this$_options$numWor | ||
: Math.max((0, _os().cpus)().length - 1, 1), | ||
resourceLimits: | ||
(_this$_options$resour = this._options.resourceLimits) !== null && | ||
_this$_options$resour !== void 0 | ||
? _this$_options$resour | ||
: {}, | ||
setupArgs: | ||
(_this$_options$setupA = this._options.setupArgs) !== null && | ||
_this$_options$setupA !== void 0 | ||
? _this$_options$setupA | ||
: [] | ||
this._options.numWorkers ?? Math.max((0, _os().cpus)().length - 1, 1), | ||
resourceLimits: this._options.resourceLimits ?? {}, | ||
setupArgs: this._options.setupArgs ?? [] | ||
}; | ||
@@ -164,0 +134,0 @@ |
@@ -65,11 +65,3 @@ 'use strict'; | ||
) { | ||
var _workerQueue$poll$tas, _workerQueue$poll; | ||
return (_workerQueue$poll$tas = | ||
(_workerQueue$poll = workerQueue.poll()) === null || | ||
_workerQueue$poll === void 0 | ||
? void 0 | ||
: _workerQueue$poll.task) !== null && _workerQueue$poll$tas !== void 0 | ||
? _workerQueue$poll$tas | ||
: null; | ||
return workerQueue.poll()?.task ?? null; | ||
} | ||
@@ -97,7 +89,3 @@ | ||
peek() { | ||
var _this$_heap$; | ||
return (_this$_heap$ = this._heap[0]) !== null && _this$_heap$ !== void 0 | ||
? _this$_heap$ | ||
: null; | ||
return this._heap[0] ?? null; | ||
} | ||
@@ -135,8 +123,7 @@ | ||
if (result == null || nodes.length === 0) { | ||
return result !== null && result !== void 0 ? result : null; | ||
return result ?? null; | ||
} | ||
let index = 0; | ||
nodes[0] = | ||
lastElement !== null && lastElement !== void 0 ? lastElement : null; | ||
nodes[0] = lastElement ?? null; | ||
const element = nodes[0]; | ||
@@ -143,0 +130,0 @@ |
@@ -129,3 +129,2 @@ 'use strict'; | ||
// default to advanced serialization in order to match worker threads | ||
// @ts-expect-error: option does not exist on the node 12 types | ||
serialization: 'advanced', | ||
@@ -132,0 +131,0 @@ silent: true, |
@@ -229,11 +229,6 @@ 'use strict'; | ||
this._onProcessEnd = (...args) => { | ||
var _onProcessEnd; | ||
// Clean the request to avoid sending past requests to workers that fail | ||
// while waiting for a new request (timers, unhandled rejections...) | ||
this._request = null; | ||
const res = | ||
(_onProcessEnd = onProcessEnd) === null || _onProcessEnd === void 0 | ||
? void 0 | ||
: _onProcessEnd(...args); // Clean up the reference so related closures can be garbage collected. | ||
const res = onProcessEnd?.(...args); // Clean up the reference so related closures can be garbage collected. | ||
@@ -240,0 +235,0 @@ onProcessEnd = null; |
{ | ||
"name": "jest-worker", | ||
"version": "28.1.3", | ||
"version": "29.0.0-alpha.0", | ||
"repository": { | ||
@@ -29,3 +29,3 @@ "type": "git", | ||
"get-stream": "^6.0.0", | ||
"jest-leak-detector": "^28.1.3", | ||
"jest-leak-detector": "^29.0.0-alpha.0", | ||
"tsd-lite": "^0.5.6", | ||
@@ -35,3 +35,3 @@ "worker-farm": "^1.6.0" | ||
"engines": { | ||
"node": "^12.13.0 || ^14.15.0 || ^16.10.0 || >=17.0.0" | ||
"node": "^14.15.0 || ^16.10.0 || >=18.0.0" | ||
}, | ||
@@ -41,3 +41,3 @@ "publishConfig": { | ||
}, | ||
"gitHead": "2cce069800dab3fc8ca7c469b32d2e2b2f7e2bb1" | ||
"gitHead": "6862afb00307b52f32eedee977a9b3041355f184" | ||
} |
No v1
QualityPackage is not semver >=1. This means it is not stable and does not support ^ ranges.
Found 1 instance in 1 package
65709
1674
2