site/node_modules/workerpool/dist/workerpool.min.js

4 lines
21 KiB
JavaScript
Raw Permalink Normal View History

2024-10-14 06:09:33 +00:00
/*! For license information please see workerpool.min.js.LICENSE.txt */
!function(e,r){"object"==typeof exports&&"undefined"!=typeof module?r(exports):"function"==typeof define&&define.amd?define(["exports"],r):r((e="undefined"!=typeof globalThis?globalThis:e||self).workerpool={})}(this,(function(e){"use strict";var r={},t={exports:{}};!function(e){var r=function(e){return void 0!==e&&null!=e.versions&&null!=e.versions.node&&e+""=="[object process]"};e.exports.isNode=r,e.exports.platform="undefined"!=typeof process&&r(process)?"node":"browser";var t="node"===e.exports.platform&&require("worker_threads");e.exports.isMainThread="node"===e.exports.platform?(!t||t.isMainThread)&&!process.connected:"undefined"!=typeof Window,e.exports.cpus="browser"===e.exports.platform?self.navigator.hardwareConcurrency:require("os").cpus().length}(t);var n,o=t.exports,i={};function s(){if(n)return i;function e(n,i){var s=this;if(!(this instanceof e))throw new SyntaxError("Constructor must be called with the new operator");if("function"!=typeof n)throw new SyntaxError("Function parameter handler(resolve, reject) missing");var a=[],u=[];this.resolved=!1,this.rejected=!1,this.pending=!0;var c=function(e,r){a.push(e),u.push(r)};this.then=function(t,n){return new e((function(e,o){var i=t?r(t,e,o):e,s=n?r(n,e,o):o;c(i,s)}),s)};var f=function(e){return s.resolved=!0,s.rejected=!1,s.pending=!1,a.forEach((function(r){r(e)})),c=function(r,t){r(e)},f=d=function(){},s},d=function(e){return s.resolved=!1,s.rejected=!0,s.pending=!1,u.forEach((function(r){r(e)})),c=function(r,t){t(e)},f=d=function(){},s};this.cancel=function(){return i?i.cancel():d(new t),s},this.timeout=function(e){if(i)i.timeout(e);else{var r=setTimeout((function(){d(new o("Promise timed out after "+e+" ms"))}),e);s.always((function(){clearTimeout(r)}))}return s},n((function(e){f(e)}),(function(e){d(e)}))}function r(e,r,t){return function(n){try{var o=e(n);o&&"function"==typeof o.then&&"function"==typeof o.catch?o.then(r,t):r(o)}catch(e){t(e)}}}function t(e){this.message=e||"promise cancelled",this.stack=(new Error).stack}function o(e){this.message=e||"timeout exceeded",this.stack=(new Error).stack}return n=1,e.prototype.catch=function(e){return this.then(null,e)},e.prototype.always=function(e){return this.then(e,e)},e.all=function(r){return new e((function(e,t){var n=r.length,o=[];n?r.forEach((function(r,i){r.then((function(r){o[i]=r,0==--n&&e(o)}),(function(e){n=0,t(e)}))})):e(o)}))},e.defer=function(){var r={};return r.promise=new e((function(e,t){r.resolve=e,r.reject=t})),r},t.prototype=new Error,t.prototype.constructor=Error,t.prototype.name="CancellationError",e.CancellationError=t,o.prototype=new Error,o.prototype.constructor=Error,o.prototype.name="TimeoutError",e.TimeoutError=o,i.Promise=e,i}var a,u,c,f,d,p,h,l,m={exports:{}},k={};function w(){return a||(a=1,k.validateOptions=function(e,r,t){if(e){var n=e?Object.keys(e):[],o=n.find((e=>!r.includes(e)));if(o)throw new Error('Object "'+t+'" contains an unknown option "'+o+'"');var i=r.find((e=>Object.prototype[e]&&!n.includes(e)));if(i)throw new Error('Object "'+t+'" contains an inherited option "'+i+'" which is not defined in the object itself but in its prototype. Only plain objects are allowed. Please remove the option from the prototype or override it with a value "undefined".');return e}},k.workerOptsNames=["credentials","name","type"],k.forkOptsNames=["cwd","detached","env","execPath","execArgv","gid","serialization","signal","killSignal","silent","stdio","uid","windowsVerbatimArguments","timeout"],k.workerThreadOptsNames=["argv","env","eval","execArgv","stdin","stdout","stderr","workerData","trackUnmanagedFds","transferList","resourceLimits","name"]),k}function v(){if(f)return m.exports;f=1;var{Promise:e}=s(),r=o;const{validateOptions:t,forkOptsNames:n,workerThreadOptsNames:i,workerOptsNames:a}=w();var d="__workerpool-terminate__";function p(){var e=l();if(!e)throw new Error("WorkerPool: workerType = 'thread' is not supported, Node >= 11.7.0 required");return e}function h(){if("function"!=typeof Worker&&("object"!=typeof Worker||"function"!=typeof Worker.prototype.constructor))throw new Error
//# sourceMappingURL=workerpool.min.js.map