source: imaps-frontend/node_modules/fflate/lib/node-worker.cjs@ 79a0317

main
Last change on this file since 79a0317 was 79a0317, checked in by stefan toskovski <stefantoska84@…>, 3 days ago

F4 Finalna Verzija

  • Property mode set to 100644
File size: 1.1 KB
Line 
1"use strict";
2// Mediocre shim
3var Worker;
4var workerAdd = ";var __w=require('worker_threads');__w.parentPort.on('message',function(m){onmessage({data:m})}),postMessage=function(m,t){__w.parentPort.postMessage(m,t)},close=process.exit;self=global";
5try {
6 Worker = require('worker_threads').Worker;
7}
8catch (e) {
9}
10exports.default = Worker ? function (c, _, msg, transfer, cb) {
11 var done = false;
12 var w = new Worker(c + workerAdd, { eval: true })
13 .on('error', function (e) { return cb(e, null); })
14 .on('message', function (m) { return cb(null, m); })
15 .on('exit', function (c) {
16 if (c && !done)
17 cb(new Error('exited with code ' + c), null);
18 });
19 w.postMessage(msg, transfer);
20 w.terminate = function () {
21 done = true;
22 return Worker.prototype.terminate.call(w);
23 };
24 return w;
25} : function (_, __, ___, ____, cb) {
26 setImmediate(function () { return cb(new Error('async operations unsupported - update to Node 12+ (or Node 10-11 with the --experimental-worker CLI flag)'), null); });
27 var NOP = function () { };
28 return {
29 terminate: NOP,
30 postMessage: NOP
31 };
32};
Note: See TracBrowser for help on using the repository browser.