@creejs/commons-retrier 2.1.27 → 2.1.29
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/esm/index-dev.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
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: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;
|
|
1
|
+
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;
|
|
2
2
|
|
|
3
3
|
// module vars
|
|
4
4
|
const DefaultMinInterval = 50;
|
|
@@ -8,7 +8,7 @@ const DefaultMaxRetries = 3;
|
|
|
8
8
|
// internal
|
|
9
9
|
|
|
10
10
|
// module vars
|
|
11
|
-
const { assertPositive: assertPositive$5, assertNotNegative: assertNotNegative$3 } =
|
|
11
|
+
const { assertPositive: assertPositive$5, assertNotNegative: assertNotNegative$3 } = M;
|
|
12
12
|
const { isNumber } = u$1;
|
|
13
13
|
|
|
14
14
|
class Policy {
|
|
@@ -179,7 +179,7 @@ var Event = {
|
|
|
179
179
|
// 3rd
|
|
180
180
|
// internal
|
|
181
181
|
// module vars
|
|
182
|
-
const { assertPositive: assertPositive$4 } =
|
|
182
|
+
const { assertPositive: assertPositive$4 } = M;
|
|
183
183
|
class FixedIntervalPolicy extends Policy {
|
|
184
184
|
/**
|
|
185
185
|
* Creates a fixed interval retry policy with the specified interval.
|
|
@@ -223,7 +223,7 @@ class FixedIntervalPolicy extends Policy {
|
|
|
223
223
|
// 3rd
|
|
224
224
|
// internal
|
|
225
225
|
// module vars
|
|
226
|
-
const { assertPositive: assertPositive$3 } =
|
|
226
|
+
const { assertPositive: assertPositive$3 } = M;
|
|
227
227
|
class FixedIncreasePolicy extends Policy {
|
|
228
228
|
/**
|
|
229
229
|
* each call to _next() increases the interval by "increasement".
|
|
@@ -260,7 +260,7 @@ class FixedIncreasePolicy extends Policy {
|
|
|
260
260
|
// 3rd
|
|
261
261
|
// internal
|
|
262
262
|
// module vars
|
|
263
|
-
const { assertPositive: assertPositive$2 } =
|
|
263
|
+
const { assertPositive: assertPositive$2 } = M;
|
|
264
264
|
|
|
265
265
|
class FactoreIncreasePolicy extends Policy {
|
|
266
266
|
/**
|
|
@@ -304,7 +304,7 @@ class FactoreIncreasePolicy extends Policy {
|
|
|
304
304
|
// 3rd
|
|
305
305
|
// internal
|
|
306
306
|
// module vars
|
|
307
|
-
const { assertPositive: assertPositive$1 } =
|
|
307
|
+
const { assertPositive: assertPositive$1 } = M;
|
|
308
308
|
|
|
309
309
|
class ShuttlePolicy extends Policy {
|
|
310
310
|
/**
|
|
@@ -349,7 +349,7 @@ class ShuttlePolicy extends Policy {
|
|
|
349
349
|
|
|
350
350
|
// internal
|
|
351
351
|
// module vars
|
|
352
|
-
const { assertNotNegative: assertNotNegative$2 } =
|
|
352
|
+
const { assertNotNegative: assertNotNegative$2 } = M;
|
|
353
353
|
/**
|
|
354
354
|
* @class FixedBackoff
|
|
355
355
|
*/
|
|
@@ -369,7 +369,7 @@ class FixedBackoff extends FixedIntervalPolicy {
|
|
|
369
369
|
// internal
|
|
370
370
|
|
|
371
371
|
// module vars
|
|
372
|
-
const { assertNotNegative: assertNotNegative$1 } =
|
|
372
|
+
const { assertNotNegative: assertNotNegative$1 } = M;
|
|
373
373
|
/**
|
|
374
374
|
* @class ExponentialBackoffPolicy
|
|
375
375
|
*/
|
|
@@ -387,7 +387,7 @@ class ExponentialBackoffPolicy extends FactoreIncreasePolicy {
|
|
|
387
387
|
|
|
388
388
|
// internal
|
|
389
389
|
// module vars
|
|
390
|
-
const { assertNotNegative } =
|
|
390
|
+
const { assertNotNegative } = M;
|
|
391
391
|
/**
|
|
392
392
|
* @class LinearBackoff
|
|
393
393
|
*/
|
|
@@ -411,7 +411,7 @@ class LinearBackoff extends FixedIncreasePolicy {
|
|
|
411
411
|
*/
|
|
412
412
|
|
|
413
413
|
// module vars
|
|
414
|
-
const { assertNotNil, assertFunction: assertFunction$1 } =
|
|
414
|
+
const { assertNotNil, assertFunction: assertFunction$1 } = M;
|
|
415
415
|
class Task {
|
|
416
416
|
/**
|
|
417
417
|
* Creates a new Task instance.
|
|
@@ -558,7 +558,7 @@ class ForeverTask extends Task {
|
|
|
558
558
|
*/
|
|
559
559
|
|
|
560
560
|
// module vars
|
|
561
|
-
const { assertPositive, assertString, assertFunction, assertNumber } =
|
|
561
|
+
const { assertPositive, assertString, assertFunction, assertNumber } = M;
|
|
562
562
|
const { isNil } = u$1;
|
|
563
563
|
const TaskTimoutFlag = '!#@%$&^*';
|
|
564
564
|
|
|
@@ -1119,7 +1119,7 @@ class Retrier {
|
|
|
1119
1119
|
if (this._taskingFlag != null) {
|
|
1120
1120
|
return this._taskingFlag.promise
|
|
1121
1121
|
}
|
|
1122
|
-
this._taskingFlag =
|
|
1122
|
+
this._taskingFlag = et.defer();
|
|
1123
1123
|
|
|
1124
1124
|
if (ForeverTask.isForeverTask(this._task)) {
|
|
1125
1125
|
// DO NOT care ForeverTask's result
|
|
@@ -1164,7 +1164,7 @@ class Retrier {
|
|
|
1164
1164
|
if (this._sleepWaiter != null) {
|
|
1165
1165
|
this._sleepWaiter.wakeup();
|
|
1166
1166
|
}
|
|
1167
|
-
this._breakFlag =
|
|
1167
|
+
this._breakFlag = et.defer();
|
|
1168
1168
|
/** @type {Error|undefined} */
|
|
1169
1169
|
this._breakReason = reason ?? new Error('Manually Stop');
|
|
1170
1170
|
// @ts-ignore
|
|
@@ -1323,7 +1323,7 @@ class Retrier {
|
|
|
1323
1323
|
const nextDelay = this._policy.generate(this._currentRetries);
|
|
1324
1324
|
try {
|
|
1325
1325
|
try {
|
|
1326
|
-
await
|
|
1326
|
+
await et.timeout(task.execute(this._currentRetries, latency, nextDelay), this._taskTimeout, TaskTimoutFlag);
|
|
1327
1327
|
} catch (err) {
|
|
1328
1328
|
// @ts-ignore
|
|
1329
1329
|
if (err.message === TaskTimoutFlag) {
|
|
@@ -1347,7 +1347,7 @@ class Retrier {
|
|
|
1347
1347
|
// compute next retry counter
|
|
1348
1348
|
++this._currentRetries;
|
|
1349
1349
|
// use Waiter to introduce the ability to wakeup at any time
|
|
1350
|
-
this._sleepWaiter =
|
|
1350
|
+
this._sleepWaiter = et.wait(nextDelay);
|
|
1351
1351
|
await this._sleepWaiter.promise;
|
|
1352
1352
|
}
|
|
1353
1353
|
}
|
|
@@ -1403,7 +1403,7 @@ class Retrier {
|
|
|
1403
1403
|
const nextDelay = this._policy.generate(this._currentRetries);
|
|
1404
1404
|
try {
|
|
1405
1405
|
try {
|
|
1406
|
-
await
|
|
1406
|
+
await et.timeout(task.execute(this._currentRetries, latency, nextDelay), this._taskTimeout, TaskTimoutFlag);
|
|
1407
1407
|
} catch (err) {
|
|
1408
1408
|
// @ts-ignore
|
|
1409
1409
|
if (err.message === TaskTimoutFlag) {
|
|
@@ -1445,7 +1445,7 @@ class Retrier {
|
|
|
1445
1445
|
break
|
|
1446
1446
|
}
|
|
1447
1447
|
// use Waiter to introduce the ability to wakeup at any time
|
|
1448
|
-
this._sleepWaiter =
|
|
1448
|
+
this._sleepWaiter = et.wait(nextDelay);
|
|
1449
1449
|
await this._sleepWaiter.promise;
|
|
1450
1450
|
// await PromiseUtils.delay(nextDelay)
|
|
1451
1451
|
}
|