@creejs/commons-retrier 2.1.26 → 2.1.28
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/cjs/index-dev.cjs +17 -17
- package/dist/cjs/index-dev.cjs.map +1 -1
- package/dist/cjs/index-min.cjs.map +1 -1
- package/dist/esm/index-dev.js +17 -17
- package/dist/esm/index-dev.js.map +1 -1
- package/dist/esm/index-min.js.map +1 -1
- package/dist/umd/index.dev.js +17 -17
- package/dist/umd/index.dev.js.map +1 -1
- package/dist/umd/index.min.js.map +1 -1
- package/package.json +3 -3
package/dist/umd/index.dev.js
CHANGED
|
@@ -4,7 +4,7 @@
|
|
|
4
4
|
(global = typeof globalThis !== 'undefined' ? globalThis : global || self, factory(global.CommonsLang = {}));
|
|
5
5
|
})(this, (function (exports) { 'use strict';
|
|
6
6
|
|
|
7
|
-
let e$1 = class e extends Error{static isAggregatedErrorLike(t){return t&&Array.isArray(t.errors)}static isAggregatedError(t){return t instanceof e}constructor(t,r){super(t),this.errors=r??[];}addError(t){this.errors.push(t);}removeError(t){const r=this.errors.indexOf(t);return -1!==r&&(this.errors.splice(r,1),true)}};var n$1={constructorName:o$1,defaults:function(t,...r){if(null==t)throw new TypeError('"target" Should Not Nil');for(const e of r)if(null!=e)for(const r in e) void 0===t[r]&&(t[r]=e[r]);return t},extend:i$1,extends:i$1,equals:function(t,r){if(t===r)return true;if("function"==typeof t?.equals)return t.equals(r);if("function"==typeof r?.equals)return r.equals(t);return false},isBrowser:s$1,isNode:function(){return !s$1()},cloneToPlainObject:function(t){if(null==t)return t;if("object"!=typeof t)throw new Error("Only Object allowed to clone");return {...t}},deepCloneToPlainObject:function(t){if(null==t)return t;if("object"!=typeof t)throw new Error("Only Object allowed to clone");return JSON.parse(JSON.stringify(t))}};function o$1(t){return t?.constructor?.name}function i$1(t,...r){if(null==t)throw new TypeError('"target" must not be null or undefined');for(const e of r)if(null!=e)for(const r in e)t[r]=e[r];return t}function s$1(){return "undefined"!=typeof window&&"undefined"!=typeof document}var u$1={isArray:f$1,isBoolean:a$1,isBuffer:function(t){return null!=t&&Buffer.isBuffer(t)},isFunction:c$1,isInstance:l$1,isIterable:function(t){return null!=t&&"function"==typeof t[Symbol.iterator]},isDate:function(t){return null!=t&&t instanceof Date},isError:function(t){return null!=t&&t instanceof Error},isMap:function(t){return null!=t&&"object"==typeof t&&t.constructor===Map},isWeakMap:function(t){return null!=t&&"object"==typeof t&&t.constructor===WeakMap},isNumber:m$1,isPositive:p$1,isNegative:g$1,isNotNegative:h$1,isNil:y,isNullOrUndefined:function(t){return null==t},isNull:w$1,isUndefined:d$1,isPlainObject:A,isObject:b$1,isPromise:E,isRegExp:function(t){return null!=t&&"object"==typeof t&&t.constructor===RegExp},isSet:function(t){return null!=t&&"object"==typeof t&&t.constructor===Set},isWeakSet:function(t){return null!=t&&"object"==typeof t&&t.constructor===WeakSet},isStream:function(t){return null!=t&&"function"==typeof t.pipe},isString:N,isSymbol:$,isPrimitive:function(t){return null!==t&&("string"==typeof t||"number"==typeof t||"boolean"==typeof t)},isInt8Array:v$1,isUint8Array:P,isUint8ClampedArray:j,isInt16Array:S,isUint16Array:x,isInt32Array:U,isUint32Array:T,isFloat32Array:I,isFloat64Array:B,isBigInt64Array:k$1,isBigUint64Array:L$1,isTypedArray:O$1,isArrayBuffer:F};function f$1(t){return Array.isArray(t)}function a$1(t){return "boolean"==typeof t}function c$1(t){return "function"==typeof t}function l$1(t){return null!=t&&"object"==typeof t&&!A(t)}function y(t){return null==t}function p$1(t){return !!m$1(t)&&t>0}function h$1(t){return !!m$1(t)&&t>=0}function g$1(t){return !!m$1(t)&&t<0}function w$1(t){return null===t}function d$1(t){return void 0===t}function m$1(t){return null!=t&&"number"==typeof t}function b$1(t){return null!=t&&"object"==typeof t}function A(t){return null!==t&&"object"==typeof t&&(t.constructor===Object||void 0===t.constructor)}function E(t){return null!=t&&"function"==typeof t.then}function N(t){return null!=t&&"string"==typeof t}function $(t){return null!=t&&"symbol"==typeof t}function O$1(t){return ArrayBuffer.isView(t)&&t.constructor!==DataView}function v$1(t){return t instanceof Int8Array}function P(t){return t instanceof Uint8Array}function j(t){return t instanceof Uint8ClampedArray}function S(t){return t instanceof Int16Array}function x(t){return t instanceof Uint16Array}function U(t){return t instanceof Int32Array}function T(t){return t instanceof Uint32Array}function I(t){return t instanceof Float32Array}function B(t){return t instanceof Float64Array}function k$1(t){return t instanceof BigInt64Array}function L$1(t){return t instanceof BigUint64Array}function F(t){return t instanceof ArrayBuffer}var C={assertNumber:q,assertPositive:_$1,assertNotNegative:R,assertFunction:W,assertNotNil:V,assertString:D};function M(t,r){if(!Array.isArray(t))throw new Error(`${r?'"'+r+'" ':""}Not Array: type=${typeof t} value=${Z(t)}`)}function D(t,r){if(!N(t))throw new Error(`${r?'"'+r+'" ':""}Not String: type=${typeof t} value=${Z(t)}`)}function q(t,r){if(!m$1(t))throw new Error(`${r?'"'+r+'" ':""}Not Number: type=${typeof t} value=${Z(t)}`)}function _$1(t,r){if(!p$1(t))throw new Error(`${r?'"'+r+'" ':""}Not Positive: ${t}`)}function R(t,r){if(!h$1(t))throw new Error(`${r?'"'+r+'" ':""}Not "0 or Positive": ${t}`)}function W(t,r){if(!c$1(t))throw new Error(`${r?'"'+r+'" ':""}Not Function: type=${typeof t} value=${Z(t)}`)}function H(t,r){if(!E(t))throw new Error(`${r?'"'+r+'" ':""}Not Promise: type=${typeof t} value=${Z(t)}`)}function V(t,r){if(y(t))throw new Error((r?'"'+r+'" ':"")+"Should Not Nil")}function Z(t){if(null===t)return "null";if(void 0===t)return "undefined";const r=typeof t;if("string"===r)return t;if("symbol"===r)return `Symbol(${t.description})`;if("function"===r)return `Function ${t.name}(){}`;if(t instanceof String)return t.toString();if(Number.isNaN(t))return "NaN";if(t===1/0)return "Infinity";if(t===-1/0)return "-Infinity";if(t instanceof Error)return `${t.constructor.name}: ${t.message}`;if(t instanceof Promise)return "Promise";if(t instanceof Set)return `Set: ${Z(Array.from(t))}`;if(t instanceof Map)return `Map: ${Z(Array.from(t.entries()))}`;if(t instanceof RegExp)return t.toString();if(Array.isArray(t))return `[${t.map(Z).join(", ")}]`;let e;try{e=JSON.stringify(t);}catch(r){e=t.toString();}return e}var rt={any:function(t){if(M(t),0===t.length)throw new Error("Empty Tasks");const r=et(),n=[];for(let o=0;o<t.length;o++){const i=t[o];let s;if(u$1.isPromise(i))s=i;else {if(!u$1.isFunction(i)){n.push(new Error(`Invalid Task at index ${o}/${t.length-1}: ${i}`));continue}s=ot(i);}s.then(t=>{r.resolve(t);}).catch(o=>{n.push(o),n.length>=t.length&&r.reject(new e$1("All Tasks Failed",n));});}n.length===t.length&&r.reject(new e$1("All Tasks Failed",n));return r.promise},defer:et,delay:function(t,r){u$1.isNumber(t)?(r=t,t=Promise.resolve()):null==t&&null==r&&(r=1,t=Promise.resolve());null!=t&&H(t),q(r=r??1e3);const e=et(),n=Date.now();return t.then((...t)=>{const o=Date.now()-n;o<r?setTimeout(()=>e.resolve(...t),r-o):e.resolve(...t);}).catch(t=>{const o=Date.now()-n;o<r?setTimeout(()=>e.reject(t),r-o):e.reject(t);}),e.promise},timeout:function(t,r,e){H(t),q(r=r??1);const n=et(r,e),o=Date.now();return t.then((...t)=>{Date.now()-o<=r?n.resolve(...t):n.reject(new Error(e??`Promise Timeout: ${r}ms`));}).catch(t=>{!n.resolved&&!n.rejected&&n.reject(t);}),n.promise},allSettled:nt,returnValuePromised:ot,series:async function(t){M(t);const r=[];for(const e of t)if(W(e),u$1.isFunction(e))r.push(await ot(e));else {if(!u$1.isPromise(e))throw new Error(`Invalid Task: ${e}`);r.push(await e);}return r},seriesAllSettled:async function(t){M(t);const r=[];for(const e of t){W(e);try{r.push({ok:!0,result:await e()});}catch(t){r.push({ok:false,result:t});}}return r},parallel:async function(t,r=5){if(M(t),q(r),r<=0)throw new Error(`Invalid maxParallel: ${r}, should > 0`);t.forEach(t=>W(t));const e=[];if(t.length<=r){const r=await Promise.all(t.map(t=>ot(t)));return e.push(...r),e}const n=[];for(const o of t)if(W(o),n.push(o),n.length>=r){const t=await Promise.all(n.map(t=>ot(t)));e.push(...t),n.length=0;}if(n.length>0&&n.length<r){const t=await Promise.all(n.map(t=>ot(t)));e.push(...t);}return e},parallelAny:async function(t,r=5,n){if(M(t,"tasks"),q(r),0===t.length)throw new Error("Empty Tasks");if(r<=0)throw new Error(`Invalid maxParallel: ${r}, should > 0`);const o=[];let i=0,s=0;const f=et();function a(){if(i>=t.length)return;if(s>r)return;const c=t[i++];let l;s++,l=u$1.isPromise(c)?c:u$1.isFunction(c)?ot(c):Promise.reject(new TypeError(`Invalid task: ${typeof c}, Only Promise or Function allowed`)),l.then(t=>{s--,f.resolve(t);}).catch(r=>{o.push(r),o.length>=t.length&&f.pending?f.reject(new e$1(n??"All Tasks Failed",o)):(s--,a());});}const c=Math.min(t.length,r);for(let t=0;t<c;t++)a();return f.promise},parallelAllSettled:async function(t,r=5){if(M(t),q(r),r<=0)throw new Error(`Invalid maxParallel: ${r}, should > 0`);t.forEach(t=>W(t));const e=[];if(t.length<=r){const r=await nt(t.map(t=>ot(t)));return e.push(...r),e}const n=[];for(const o of t)if(n.push(o),n.length>=r){const t=await nt(n.map(t=>ot(t)));e.push(...t),n.length=0;}if(n.length>0&&n.length<r){const t=await nt(n.map(t=>ot(t)));e.push(...t);}return e},wait:function(t){R(t);const r={};let e;return r.timerHandler=e=setTimeout(()=>{clearTimeout(e),r._resolve();},t),r.promise=new Promise((t,n)=>{r._resolve=r=>{null!=e&&clearTimeout(e),t(r);};}),r.wakeup=()=>{r._resolve();},r}};function et(t=-1,r){q(t);const e={};let n;return e.pending=true,e.canceled=false,e.rejected=false,e.resolved=false,t>=0&&(e.timerCleared=false,e.timerHandler=n=setTimeout(()=>{clearTimeout(n),e.timerCleared=true,e.reject(new Error(r??`Promise Timeout: ${t}ms`));},t)),e.promise=new Promise((t,r)=>{e.resolve=r=>{e.resolved||e.rejected||e.canceled||(null!=n&&(clearTimeout(n),e.timerCleared=true),e.pending=false,e.canceled=false,e.rejected=false,e.resolved=true,t(r));},e.reject=t=>{e.resolved||e.rejected||e.canceled||(null!=n&&(clearTimeout(n),e.timerCleared=true),e.pending=false,e.canceled=false,e.resolved=false,e.rejected=true,r(t));};}),e.cancel=e.promise.cancel=t=>{e.resolved||e.rejected||e.canceled||(null!=n&&(clearTimeout(n),e.timerCleared=true),e.reject(t??new Error("Cancelled")),e.canceled=e.promise.canceled=true);},e}async function nt(t){M(t);const r=await Promise.allSettled(t),e=[];for(const t of r)"fulfilled"===t.status&&e.push({ok:true,result:t.value}),"rejected"===t.status&&e.push({ok:false,result:t.reason});return e}function ot(t){try{const r=t();return u$1.isPromise(r)?r:Promise.resolve(r)}catch(t){return Promise.reject(t)}}new TextDecoder;new TextEncoder;
|
|
7
|
+
let e$1 = class e extends Error{static isAggregatedErrorLike(t){return t&&Array.isArray(t.errors)}static isAggregatedError(t){return t instanceof e}constructor(t,r){super(t),this.errors=r??[];}addError(t){this.errors.push(t);}removeError(t){const r=this.errors.indexOf(t);return -1!==r&&(this.errors.splice(r,1),true)}};var n$1={get:function(t,r,e){if(null==t)return e;if("string"!=typeof r)throw new Error('"path" must be a string');const n=r.split(".");let o=t;for(const t of n){if(void 0===o[t])return e;o=o[t];}return o},constructorName:o$1,defaults:function(t,...r){if(null==t)throw new TypeError('"target" Should Not Nil');for(const e of r)if(null!=e)for(const r in e) void 0===t[r]&&(t[r]=e[r]);return t},extend:i$1,extends:i$1,equals:function(t,r){if(t===r)return true;if("function"==typeof t?.equals)return t.equals(r);if("function"==typeof r?.equals)return r.equals(t);return false},isBrowser:s$1,isNode:function(){return !s$1()},cloneToPlainObject:function(t){if(null==t)return t;if("object"!=typeof t)throw new Error("Only Object allowed to clone");return {...t}},deepCloneToPlainObject:function(t){if(null==t)return t;if("object"!=typeof t)throw new Error("Only Object allowed to clone");return JSON.parse(JSON.stringify(t))}};function o$1(t){return t?.constructor?.name}function i$1(t,...r){if(null==t)throw new TypeError('"target" must not be null or undefined');for(const e of r)if(null!=e)for(const r in e)t[r]=e[r];return t}function s$1(){return "undefined"!=typeof window&&"undefined"!=typeof document}var u$1={isArray:f$1,isBoolean:a$1,isBuffer:function(t){return null!=t&&Buffer.isBuffer(t)},isFunction:c$1,isInstance:l$1,isIterable:y,isDate:function(t){return null!=t&&t instanceof Date},isError:function(t){return null!=t&&t instanceof Error},isMap:function(t){return null!=t&&"object"==typeof t&&t.constructor===Map},isWeakMap:function(t){return null!=t&&"object"==typeof t&&t.constructor===WeakMap},isNumber:b$1,isPositive:h$1,isNegative:w$1,isNotNegative:g$1,isNil:p$1,isNullOrUndefined:function(t){return null==t},isNull:d$1,isUndefined:m$1,isPlainObject:E,isObject:A,isPromise:N,isRegExp:function(t){return null!=t&&"object"==typeof t&&t.constructor===RegExp},isSet:function(t){return null!=t&&"object"==typeof t&&t.constructor===Set},isWeakSet:function(t){return null!=t&&"object"==typeof t&&t.constructor===WeakSet},isStream:function(t){return null!=t&&"function"==typeof t.pipe},isString:$,isSymbol:v$1,isPrimitive:function(t){return null!==t&&("string"==typeof t||"number"==typeof t||"boolean"==typeof t)},isInt8Array:P,isUint8Array:j,isUint8ClampedArray:S,isInt16Array:x,isUint16Array:U,isInt32Array:I,isUint32Array:T,isFloat32Array:B,isFloat64Array:k$1,isBigInt64Array:L$1,isBigUint64Array:F,isTypedArray:O$1,isArrayBuffer:C};function f$1(t){return Array.isArray(t)}function a$1(t){return "boolean"==typeof t}function c$1(t){return "function"==typeof t}function l$1(t){return null!=t&&"object"==typeof t&&!E(t)}function y(t){return null!=t&&"function"==typeof t[Symbol.iterator]}function p$1(t){return null==t}function h$1(t){return !!b$1(t)&&t>0}function g$1(t){return !!b$1(t)&&t>=0}function w$1(t){return !!b$1(t)&&t<0}function d$1(t){return null===t}function m$1(t){return void 0===t}function b$1(t){return null!=t&&"number"==typeof t}function A(t){return null!=t&&"object"==typeof t}function E(t){return null!==t&&"object"==typeof t&&(t.constructor===Object||void 0===t.constructor)}function N(t){return null!=t&&"function"==typeof t.then}function $(t){return null!=t&&"string"==typeof t}function v$1(t){return null!=t&&"symbol"==typeof t}function O$1(t){return ArrayBuffer.isView(t)&&t.constructor!==DataView}function P(t){return t instanceof Int8Array}function j(t){return t instanceof Uint8Array}function S(t){return t instanceof Uint8ClampedArray}function x(t){return t instanceof Int16Array}function U(t){return t instanceof Uint16Array}function I(t){return t instanceof Int32Array}function T(t){return t instanceof Uint32Array}function B(t){return t instanceof Float32Array}function k$1(t){return t instanceof Float64Array}function L$1(t){return t instanceof BigInt64Array}function F(t){return t instanceof BigUint64Array}function C(t){return t instanceof ArrayBuffer}var M={assertNumber:_$1,assertPositive:R,assertNotNegative:J,assertFunction:z,assertNotNil:V,assertString:q};function D(t,r){if(!Array.isArray(t))throw new Error(`${r?'"'+r+'" ':""}Not Array: type=${typeof t} value=${tt(t)}`)}function q(t,r){if(!$(t))throw new Error(`${r?'"'+r+'" ':""}Not String: type=${typeof t} value=${tt(t)}`)}function _$1(t,r){if(!b$1(t))throw new Error(`${r?'"'+r+'" ':""}Not Number: type=${typeof t} value=${tt(t)}`)}function R(t,r){if(!h$1(t))throw new Error(`${r?'"'+r+'" ':""}Not Positive: ${t}`)}function J(t,r){if(!g$1(t))throw new Error(`${r?'"'+r+'" ':""}Not "0 or Positive": ${t}`)}function z(t,r){if(!c$1(t))throw new Error(`${r?'"'+r+'" ':""}Not Function: type=${typeof t} value=${tt(t)}`)}function H(t,r){if(!N(t))throw new Error(`${r?'"'+r+'" ':""}Not Promise: type=${typeof t} value=${tt(t)}`)}function V(t,r){if(p$1(t))throw new Error((r?'"'+r+'" ':"")+"Should Not Nil")}function tt(t){if(null===t)return "null";if(void 0===t)return "undefined";const r=typeof t;if("string"===r)return t;if("symbol"===r)return `Symbol(${t.description})`;if("function"===r)return `Function ${t.name}(){}`;if(t instanceof String)return t.toString();if(Number.isNaN(t))return "NaN";if(t===1/0)return "Infinity";if(t===-1/0)return "-Infinity";if(t instanceof Error)return `${t.constructor.name}: ${t.message}`;if(t instanceof Promise)return "Promise";if(t instanceof Set)return `Set: ${tt(Array.from(t))}`;if(t instanceof Map)return `Map: ${tt(Array.from(t.entries()))}`;if(t instanceof RegExp)return t.toString();if(Array.isArray(t))return `[${t.map(tt).join(", ")}]`;let e;try{e=JSON.stringify(t);}catch(r){e=t.toString();}return e}var et={any:function(t){if(D(t),0===t.length)throw new Error("Empty Tasks");const r=nt(),n=[];for(let o=0;o<t.length;o++){const i=t[o];let s;if(u$1.isPromise(i))s=i;else {if(!u$1.isFunction(i)){n.push(new Error(`Invalid Task at index ${o}/${t.length-1}: ${i}`));continue}s=it(i);}s.then(t=>{r.resolve(t);}).catch(o=>{n.push(o),n.length>=t.length&&r.reject(new e$1("All Tasks Failed",n));});}n.length===t.length&&r.reject(new e$1("All Tasks Failed",n));return r.promise},defer:nt,delay:function(t,r){u$1.isNumber(t)?(r=t,t=Promise.resolve()):null==t&&null==r&&(r=1,t=Promise.resolve());null!=t&&H(t),_$1(r=r??1e3);const e=nt(),n=Date.now();return t.then((...t)=>{const o=Date.now()-n;o<r?setTimeout(()=>e.resolve(...t),r-o):e.resolve(...t);}).catch(t=>{const o=Date.now()-n;o<r?setTimeout(()=>e.reject(t),r-o):e.reject(t);}),e.promise},timeout:function(t,r,e){H(t),_$1(r=r??1);const n=nt(r,e),o=Date.now();return t.then((...t)=>{Date.now()-o<=r?n.resolve(...t):n.reject(new Error(e??`Promise Timeout: ${r}ms`));}).catch(t=>{!n.resolved&&!n.rejected&&n.reject(t);}),n.promise},allSettled:ot,returnValuePromised:it,series:async function(t){D(t);const r=[];for(const e of t)if(z(e),u$1.isFunction(e))r.push(await it(e));else {if(!u$1.isPromise(e))throw new Error(`Invalid Task: ${e}`);r.push(await e);}return r},seriesAllSettled:async function(t){D(t);const r=[];for(const e of t){z(e);try{r.push({ok:!0,result:await e()});}catch(t){r.push({ok:false,result:t});}}return r},parallel:async function(t,r=5){if(D(t),_$1(r),r<=0)throw new Error(`Invalid maxParallel: ${r}, should > 0`);t.forEach(t=>z(t));const e=[];if(t.length<=r){const r=await Promise.all(t.map(t=>it(t)));return e.push(...r),e}const n=[];for(const o of t)if(z(o),n.push(o),n.length>=r){const t=await Promise.all(n.map(t=>it(t)));e.push(...t),n.length=0;}if(n.length>0&&n.length<r){const t=await Promise.all(n.map(t=>it(t)));e.push(...t);}return e},parallelAny:async function(t,r=5,n){if(D(t,"tasks"),_$1(r),0===t.length)throw new Error("Empty Tasks");if(r<=0)throw new Error(`Invalid maxParallel: ${r}, should > 0`);const o=[];let i=0,s=0;const f=nt();function a(){if(i>=t.length)return;if(s>r)return;const c=t[i++];let l;s++,l=u$1.isPromise(c)?c:u$1.isFunction(c)?it(c):Promise.reject(new TypeError(`Invalid task: ${typeof c}, Only Promise or Function allowed`)),l.then(t=>{s--,f.resolve(t);}).catch(r=>{o.push(r),o.length>=t.length&&f.pending?f.reject(new e$1(n??"All Tasks Failed",o)):(s--,a());});}const c=Math.min(t.length,r);for(let t=0;t<c;t++)a();return f.promise},parallelAllSettled:async function(t,r=5){if(D(t),_$1(r),r<=0)throw new Error(`Invalid maxParallel: ${r}, should > 0`);t.forEach(t=>z(t));const e=[];if(t.length<=r){const r=await ot(t.map(t=>it(t)));return e.push(...r),e}const n=[];for(const o of t)if(n.push(o),n.length>=r){const t=await ot(n.map(t=>it(t)));e.push(...t),n.length=0;}if(n.length>0&&n.length<r){const t=await ot(n.map(t=>it(t)));e.push(...t);}return e},wait:function(t){J(t);const r={};let e;return r.timerHandler=e=setTimeout(()=>{clearTimeout(e),r._resolve();},t),r.promise=new Promise((t,n)=>{r._resolve=r=>{null!=e&&clearTimeout(e),t(r);};}),r.wakeup=()=>{r._resolve();},r}};function nt(t=-1,r){_$1(t);const e={};let n;return e.pending=true,e.canceled=false,e.rejected=false,e.resolved=false,t>=0&&(e.timerCleared=false,e.timerHandler=n=setTimeout(()=>{clearTimeout(n),e.timerCleared=true,e.reject(new Error(r??`Promise Timeout: ${t}ms`));},t)),e.promise=new Promise((t,r)=>{e.resolve=r=>{e.resolved||e.rejected||e.canceled||(null!=n&&(clearTimeout(n),e.timerCleared=true),e.pending=false,e.canceled=false,e.rejected=false,e.resolved=true,t(r));},e.reject=t=>{e.resolved||e.rejected||e.canceled||(null!=n&&(clearTimeout(n),e.timerCleared=true),e.pending=false,e.canceled=false,e.resolved=false,e.rejected=true,r(t));};}),e.cancel=e.promise.cancel=t=>{e.resolved||e.rejected||e.canceled||(null!=n&&(clearTimeout(n),e.timerCleared=true),e.reject(t??new Error("Cancelled")),e.canceled=e.promise.canceled=true);},e}async function ot(t){D(t);const r=await Promise.allSettled(t),e=[];for(const t of r)"fulfilled"===t.status&&e.push({ok:true,result:t.value}),"rejected"===t.status&&e.push({ok:false,result:t.reason});return e}function it(t){try{const r=t();return u$1.isPromise(r)?r:Promise.resolve(r)}catch(t){return Promise.reject(t)}}new TextDecoder;new TextEncoder;
|
|
8
8
|
|
|
9
9
|
// module vars
|
|
10
10
|
const DefaultMinInterval = 50;
|
|
@@ -14,7 +14,7 @@
|
|
|
14
14
|
// internal
|
|
15
15
|
|
|
16
16
|
// module vars
|
|
17
|
-
const { assertPositive: assertPositive$5, assertNotNegative: assertNotNegative$3 } =
|
|
17
|
+
const { assertPositive: assertPositive$5, assertNotNegative: assertNotNegative$3 } = M;
|
|
18
18
|
const { isNumber } = u$1;
|
|
19
19
|
|
|
20
20
|
class Policy {
|
|
@@ -185,7 +185,7 @@
|
|
|
185
185
|
// 3rd
|
|
186
186
|
// internal
|
|
187
187
|
// module vars
|
|
188
|
-
const { assertPositive: assertPositive$4 } =
|
|
188
|
+
const { assertPositive: assertPositive$4 } = M;
|
|
189
189
|
class FixedIntervalPolicy extends Policy {
|
|
190
190
|
/**
|
|
191
191
|
* Creates a fixed interval retry policy with the specified interval.
|
|
@@ -229,7 +229,7 @@
|
|
|
229
229
|
// 3rd
|
|
230
230
|
// internal
|
|
231
231
|
// module vars
|
|
232
|
-
const { assertPositive: assertPositive$3 } =
|
|
232
|
+
const { assertPositive: assertPositive$3 } = M;
|
|
233
233
|
class FixedIncreasePolicy extends Policy {
|
|
234
234
|
/**
|
|
235
235
|
* each call to _next() increases the interval by "increasement".
|
|
@@ -266,7 +266,7 @@
|
|
|
266
266
|
// 3rd
|
|
267
267
|
// internal
|
|
268
268
|
// module vars
|
|
269
|
-
const { assertPositive: assertPositive$2 } =
|
|
269
|
+
const { assertPositive: assertPositive$2 } = M;
|
|
270
270
|
|
|
271
271
|
class FactoreIncreasePolicy extends Policy {
|
|
272
272
|
/**
|
|
@@ -310,7 +310,7 @@
|
|
|
310
310
|
// 3rd
|
|
311
311
|
// internal
|
|
312
312
|
// module vars
|
|
313
|
-
const { assertPositive: assertPositive$1 } =
|
|
313
|
+
const { assertPositive: assertPositive$1 } = M;
|
|
314
314
|
|
|
315
315
|
class ShuttlePolicy extends Policy {
|
|
316
316
|
/**
|
|
@@ -355,7 +355,7 @@
|
|
|
355
355
|
|
|
356
356
|
// internal
|
|
357
357
|
// module vars
|
|
358
|
-
const { assertNotNegative: assertNotNegative$2 } =
|
|
358
|
+
const { assertNotNegative: assertNotNegative$2 } = M;
|
|
359
359
|
/**
|
|
360
360
|
* @class FixedBackoff
|
|
361
361
|
*/
|
|
@@ -375,7 +375,7 @@
|
|
|
375
375
|
// internal
|
|
376
376
|
|
|
377
377
|
// module vars
|
|
378
|
-
const { assertNotNegative: assertNotNegative$1 } =
|
|
378
|
+
const { assertNotNegative: assertNotNegative$1 } = M;
|
|
379
379
|
/**
|
|
380
380
|
* @class ExponentialBackoffPolicy
|
|
381
381
|
*/
|
|
@@ -393,7 +393,7 @@
|
|
|
393
393
|
|
|
394
394
|
// internal
|
|
395
395
|
// module vars
|
|
396
|
-
const { assertNotNegative } =
|
|
396
|
+
const { assertNotNegative } = M;
|
|
397
397
|
/**
|
|
398
398
|
* @class LinearBackoff
|
|
399
399
|
*/
|
|
@@ -417,7 +417,7 @@
|
|
|
417
417
|
*/
|
|
418
418
|
|
|
419
419
|
// module vars
|
|
420
|
-
const { assertNotNil, assertFunction: assertFunction$1 } =
|
|
420
|
+
const { assertNotNil, assertFunction: assertFunction$1 } = M;
|
|
421
421
|
class Task {
|
|
422
422
|
/**
|
|
423
423
|
* Creates a new Task instance.
|
|
@@ -564,7 +564,7 @@
|
|
|
564
564
|
*/
|
|
565
565
|
|
|
566
566
|
// module vars
|
|
567
|
-
const { assertPositive, assertString, assertFunction, assertNumber } =
|
|
567
|
+
const { assertPositive, assertString, assertFunction, assertNumber } = M;
|
|
568
568
|
const { isNil } = u$1;
|
|
569
569
|
const TaskTimoutFlag = '!#@%$&^*';
|
|
570
570
|
|
|
@@ -1125,7 +1125,7 @@
|
|
|
1125
1125
|
if (this._taskingFlag != null) {
|
|
1126
1126
|
return this._taskingFlag.promise
|
|
1127
1127
|
}
|
|
1128
|
-
this._taskingFlag =
|
|
1128
|
+
this._taskingFlag = et.defer();
|
|
1129
1129
|
|
|
1130
1130
|
if (ForeverTask.isForeverTask(this._task)) {
|
|
1131
1131
|
// DO NOT care ForeverTask's result
|
|
@@ -1170,7 +1170,7 @@
|
|
|
1170
1170
|
if (this._sleepWaiter != null) {
|
|
1171
1171
|
this._sleepWaiter.wakeup();
|
|
1172
1172
|
}
|
|
1173
|
-
this._breakFlag =
|
|
1173
|
+
this._breakFlag = et.defer();
|
|
1174
1174
|
/** @type {Error|undefined} */
|
|
1175
1175
|
this._breakReason = reason ?? new Error('Manually Stop');
|
|
1176
1176
|
// @ts-ignore
|
|
@@ -1329,7 +1329,7 @@
|
|
|
1329
1329
|
const nextDelay = this._policy.generate(this._currentRetries);
|
|
1330
1330
|
try {
|
|
1331
1331
|
try {
|
|
1332
|
-
await
|
|
1332
|
+
await et.timeout(task.execute(this._currentRetries, latency, nextDelay), this._taskTimeout, TaskTimoutFlag);
|
|
1333
1333
|
} catch (err) {
|
|
1334
1334
|
// @ts-ignore
|
|
1335
1335
|
if (err.message === TaskTimoutFlag) {
|
|
@@ -1353,7 +1353,7 @@
|
|
|
1353
1353
|
// compute next retry counter
|
|
1354
1354
|
++this._currentRetries;
|
|
1355
1355
|
// use Waiter to introduce the ability to wakeup at any time
|
|
1356
|
-
this._sleepWaiter =
|
|
1356
|
+
this._sleepWaiter = et.wait(nextDelay);
|
|
1357
1357
|
await this._sleepWaiter.promise;
|
|
1358
1358
|
}
|
|
1359
1359
|
}
|
|
@@ -1409,7 +1409,7 @@
|
|
|
1409
1409
|
const nextDelay = this._policy.generate(this._currentRetries);
|
|
1410
1410
|
try {
|
|
1411
1411
|
try {
|
|
1412
|
-
await
|
|
1412
|
+
await et.timeout(task.execute(this._currentRetries, latency, nextDelay), this._taskTimeout, TaskTimoutFlag);
|
|
1413
1413
|
} catch (err) {
|
|
1414
1414
|
// @ts-ignore
|
|
1415
1415
|
if (err.message === TaskTimoutFlag) {
|
|
@@ -1451,7 +1451,7 @@
|
|
|
1451
1451
|
break
|
|
1452
1452
|
}
|
|
1453
1453
|
// use Waiter to introduce the ability to wakeup at any time
|
|
1454
|
-
this._sleepWaiter =
|
|
1454
|
+
this._sleepWaiter = et.wait(nextDelay);
|
|
1455
1455
|
await this._sleepWaiter.promise;
|
|
1456
1456
|
// await PromiseUtils.delay(nextDelay)
|
|
1457
1457
|
}
|