@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/cjs/index-dev.cjs
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
|
|
3
3
|
Object.defineProperty(exports, '__esModule', { value: true });
|
|
4
4
|
|
|
5
|
-
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;
|
|
5
|
+
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;
|
|
6
6
|
|
|
7
7
|
// module vars
|
|
8
8
|
const DefaultMinInterval = 50;
|
|
@@ -12,7 +12,7 @@ const DefaultMaxRetries = 3;
|
|
|
12
12
|
// internal
|
|
13
13
|
|
|
14
14
|
// module vars
|
|
15
|
-
const { assertPositive: assertPositive$5, assertNotNegative: assertNotNegative$3 } =
|
|
15
|
+
const { assertPositive: assertPositive$5, assertNotNegative: assertNotNegative$3 } = M;
|
|
16
16
|
const { isNumber } = u$1;
|
|
17
17
|
|
|
18
18
|
class Policy {
|
|
@@ -183,7 +183,7 @@ var Event = {
|
|
|
183
183
|
// 3rd
|
|
184
184
|
// internal
|
|
185
185
|
// module vars
|
|
186
|
-
const { assertPositive: assertPositive$4 } =
|
|
186
|
+
const { assertPositive: assertPositive$4 } = M;
|
|
187
187
|
class FixedIntervalPolicy extends Policy {
|
|
188
188
|
/**
|
|
189
189
|
* Creates a fixed interval retry policy with the specified interval.
|
|
@@ -227,7 +227,7 @@ class FixedIntervalPolicy extends Policy {
|
|
|
227
227
|
// 3rd
|
|
228
228
|
// internal
|
|
229
229
|
// module vars
|
|
230
|
-
const { assertPositive: assertPositive$3 } =
|
|
230
|
+
const { assertPositive: assertPositive$3 } = M;
|
|
231
231
|
class FixedIncreasePolicy extends Policy {
|
|
232
232
|
/**
|
|
233
233
|
* each call to _next() increases the interval by "increasement".
|
|
@@ -264,7 +264,7 @@ class FixedIncreasePolicy extends Policy {
|
|
|
264
264
|
// 3rd
|
|
265
265
|
// internal
|
|
266
266
|
// module vars
|
|
267
|
-
const { assertPositive: assertPositive$2 } =
|
|
267
|
+
const { assertPositive: assertPositive$2 } = M;
|
|
268
268
|
|
|
269
269
|
class FactoreIncreasePolicy extends Policy {
|
|
270
270
|
/**
|
|
@@ -308,7 +308,7 @@ class FactoreIncreasePolicy extends Policy {
|
|
|
308
308
|
// 3rd
|
|
309
309
|
// internal
|
|
310
310
|
// module vars
|
|
311
|
-
const { assertPositive: assertPositive$1 } =
|
|
311
|
+
const { assertPositive: assertPositive$1 } = M;
|
|
312
312
|
|
|
313
313
|
class ShuttlePolicy extends Policy {
|
|
314
314
|
/**
|
|
@@ -353,7 +353,7 @@ class ShuttlePolicy extends Policy {
|
|
|
353
353
|
|
|
354
354
|
// internal
|
|
355
355
|
// module vars
|
|
356
|
-
const { assertNotNegative: assertNotNegative$2 } =
|
|
356
|
+
const { assertNotNegative: assertNotNegative$2 } = M;
|
|
357
357
|
/**
|
|
358
358
|
* @class FixedBackoff
|
|
359
359
|
*/
|
|
@@ -373,7 +373,7 @@ class FixedBackoff extends FixedIntervalPolicy {
|
|
|
373
373
|
// internal
|
|
374
374
|
|
|
375
375
|
// module vars
|
|
376
|
-
const { assertNotNegative: assertNotNegative$1 } =
|
|
376
|
+
const { assertNotNegative: assertNotNegative$1 } = M;
|
|
377
377
|
/**
|
|
378
378
|
* @class ExponentialBackoffPolicy
|
|
379
379
|
*/
|
|
@@ -391,7 +391,7 @@ class ExponentialBackoffPolicy extends FactoreIncreasePolicy {
|
|
|
391
391
|
|
|
392
392
|
// internal
|
|
393
393
|
// module vars
|
|
394
|
-
const { assertNotNegative } =
|
|
394
|
+
const { assertNotNegative } = M;
|
|
395
395
|
/**
|
|
396
396
|
* @class LinearBackoff
|
|
397
397
|
*/
|
|
@@ -415,7 +415,7 @@ class LinearBackoff extends FixedIncreasePolicy {
|
|
|
415
415
|
*/
|
|
416
416
|
|
|
417
417
|
// module vars
|
|
418
|
-
const { assertNotNil, assertFunction: assertFunction$1 } =
|
|
418
|
+
const { assertNotNil, assertFunction: assertFunction$1 } = M;
|
|
419
419
|
class Task {
|
|
420
420
|
/**
|
|
421
421
|
* Creates a new Task instance.
|
|
@@ -562,7 +562,7 @@ class ForeverTask extends Task {
|
|
|
562
562
|
*/
|
|
563
563
|
|
|
564
564
|
// module vars
|
|
565
|
-
const { assertPositive, assertString, assertFunction, assertNumber } =
|
|
565
|
+
const { assertPositive, assertString, assertFunction, assertNumber } = M;
|
|
566
566
|
const { isNil } = u$1;
|
|
567
567
|
const TaskTimoutFlag = '!#@%$&^*';
|
|
568
568
|
|
|
@@ -1123,7 +1123,7 @@ class Retrier {
|
|
|
1123
1123
|
if (this._taskingFlag != null) {
|
|
1124
1124
|
return this._taskingFlag.promise
|
|
1125
1125
|
}
|
|
1126
|
-
this._taskingFlag =
|
|
1126
|
+
this._taskingFlag = et.defer();
|
|
1127
1127
|
|
|
1128
1128
|
if (ForeverTask.isForeverTask(this._task)) {
|
|
1129
1129
|
// DO NOT care ForeverTask's result
|
|
@@ -1168,7 +1168,7 @@ class Retrier {
|
|
|
1168
1168
|
if (this._sleepWaiter != null) {
|
|
1169
1169
|
this._sleepWaiter.wakeup();
|
|
1170
1170
|
}
|
|
1171
|
-
this._breakFlag =
|
|
1171
|
+
this._breakFlag = et.defer();
|
|
1172
1172
|
/** @type {Error|undefined} */
|
|
1173
1173
|
this._breakReason = reason ?? new Error('Manually Stop');
|
|
1174
1174
|
// @ts-ignore
|
|
@@ -1327,7 +1327,7 @@ class Retrier {
|
|
|
1327
1327
|
const nextDelay = this._policy.generate(this._currentRetries);
|
|
1328
1328
|
try {
|
|
1329
1329
|
try {
|
|
1330
|
-
await
|
|
1330
|
+
await et.timeout(task.execute(this._currentRetries, latency, nextDelay), this._taskTimeout, TaskTimoutFlag);
|
|
1331
1331
|
} catch (err) {
|
|
1332
1332
|
// @ts-ignore
|
|
1333
1333
|
if (err.message === TaskTimoutFlag) {
|
|
@@ -1351,7 +1351,7 @@ class Retrier {
|
|
|
1351
1351
|
// compute next retry counter
|
|
1352
1352
|
++this._currentRetries;
|
|
1353
1353
|
// use Waiter to introduce the ability to wakeup at any time
|
|
1354
|
-
this._sleepWaiter =
|
|
1354
|
+
this._sleepWaiter = et.wait(nextDelay);
|
|
1355
1355
|
await this._sleepWaiter.promise;
|
|
1356
1356
|
}
|
|
1357
1357
|
}
|
|
@@ -1407,7 +1407,7 @@ class Retrier {
|
|
|
1407
1407
|
const nextDelay = this._policy.generate(this._currentRetries);
|
|
1408
1408
|
try {
|
|
1409
1409
|
try {
|
|
1410
|
-
await
|
|
1410
|
+
await et.timeout(task.execute(this._currentRetries, latency, nextDelay), this._taskTimeout, TaskTimoutFlag);
|
|
1411
1411
|
} catch (err) {
|
|
1412
1412
|
// @ts-ignore
|
|
1413
1413
|
if (err.message === TaskTimoutFlag) {
|
|
@@ -1449,7 +1449,7 @@ class Retrier {
|
|
|
1449
1449
|
break
|
|
1450
1450
|
}
|
|
1451
1451
|
// use Waiter to introduce the ability to wakeup at any time
|
|
1452
|
-
this._sleepWaiter =
|
|
1452
|
+
this._sleepWaiter = et.wait(nextDelay);
|
|
1453
1453
|
await this._sleepWaiter.promise;
|
|
1454
1454
|
// await PromiseUtils.delay(nextDelay)
|
|
1455
1455
|
}
|