idmp
Advanced tools
Comparing version 1.5.2 to 1.6.0
@@ -1,18 +0,18 @@ | ||
const l = () => { | ||
const R = () => { | ||
}; | ||
const E = (e) => e < 0 ? 0 : e > 6048e5 ? 6048e5 : e; | ||
let n = {}; | ||
const r = (e) => { | ||
e && delete n[e]; | ||
let o = {}; | ||
const f = (e) => { | ||
e && delete o[e]; | ||
}, T = () => { | ||
n = {}; | ||
}, h = (e, u, A) => { | ||
o = {}; | ||
}, A = (e, c, l) => { | ||
const { | ||
maxRetry: _ = 30, | ||
maxAge: a = 3e3, | ||
onBeforeRetry: m = l | ||
} = A || {}, p = E(a); | ||
maxRetry: u = 30, | ||
maxAge: _ = 3e3, | ||
onBeforeRetry: a = R | ||
} = l || {}, m = E(_); | ||
if (!e) | ||
return u(); | ||
n[e] = n[e] || { | ||
return c(); | ||
o[e] = o[e] || { | ||
0: 0, | ||
@@ -22,3 +22,3 @@ 1: 0, | ||
}; | ||
const t = n[e], R = () => { | ||
const t = o[e], p = () => { | ||
t[ | ||
@@ -34,25 +34,36 @@ 1 | ||
] = void 0; | ||
}, c = () => { | ||
for (let s of t[ | ||
}, i = () => { | ||
const n = t[ | ||
4 | ||
/* pendingList */ | ||
]) | ||
s[0](t[ | ||
].length; | ||
for (let s = 0; s < n; ++s) | ||
t[ | ||
4 | ||
/* pendingList */ | ||
][s][0](t[ | ||
2 | ||
/* resData */ | ||
]); | ||
setTimeout(() => { | ||
r(e); | ||
}, p); | ||
}, i = () => { | ||
for (let s of t[ | ||
t[ | ||
4 | ||
/* pendingList */ | ||
]) | ||
s[1](t[ | ||
] = [], setTimeout(() => { | ||
f(e); | ||
}, m); | ||
}, d = () => { | ||
const n = t[ | ||
4 | ||
/* pendingList */ | ||
].length - u; | ||
for (let s = 0; s < n; ++s) | ||
t[ | ||
4 | ||
/* pendingList */ | ||
][s][1](t[ | ||
3 | ||
/* resError */ | ||
]); | ||
r(e); | ||
}, d = () => new Promise((s, f) => { | ||
f(e); | ||
}, h = () => new Promise((n, s) => { | ||
if (!t[ | ||
@@ -64,7 +75,7 @@ 5 | ||
/* oneCallPromiseFunc */ | ||
] = u), t[ | ||
] = c), t[ | ||
2 | ||
/* resData */ | ||
]) { | ||
s(t[ | ||
n(t[ | ||
2 | ||
@@ -79,3 +90,3 @@ /* resData */ | ||
]) { | ||
f(t[ | ||
s(t[ | ||
3 | ||
@@ -95,6 +106,6 @@ /* resError */ | ||
/* pendingList */ | ||
].push([s, f]), t[ | ||
].push([n, s]), t[ | ||
5 | ||
/* oneCallPromiseFunc */ | ||
]().then((o) => { | ||
]().then((r) => { | ||
t[ | ||
@@ -106,4 +117,4 @@ 1 | ||
/* resData */ | ||
] = o, c(); | ||
}).catch((o) => { | ||
] = r, i(); | ||
}).catch((r) => { | ||
t[ | ||
@@ -115,3 +126,3 @@ 1 | ||
/* resError */ | ||
] = o, ++t[ | ||
] = r, ++t[ | ||
0 | ||
@@ -122,3 +133,3 @@ /* retryCount */ | ||
/* retryCount */ | ||
] > _ ? i() : (m(o, { | ||
] > u ? d() : (a(r, { | ||
globalKey: e, | ||
@@ -129,3 +140,3 @@ retryCount: t[ | ||
] | ||
}), R(), setTimeout(d, (t[ | ||
}), p(), setTimeout(h, (t[ | ||
0 | ||
@@ -140,17 +151,17 @@ /* retryCount */ | ||
/* pendingList */ | ||
].push([s, f]) : t[ | ||
].push([n, s]) : t[ | ||
1 | ||
/* status */ | ||
] === 4 ? c() : t[ | ||
] === 4 ? i() : t[ | ||
1 | ||
/* status */ | ||
] === 3 && i(); | ||
] === 3 && d(); | ||
}); | ||
return d(); | ||
return h(); | ||
}; | ||
h.flush = r; | ||
h.flushAll = T; | ||
A.flush = f; | ||
A.flushAll = T; | ||
export { | ||
h as default, | ||
n as g | ||
A as default, | ||
o as g | ||
}; |
@@ -1,1 +0,1 @@ | ||
(function(n,f){typeof exports=="object"&&typeof module!="undefined"?f(exports):typeof define=="function"&&define.amd?define(["exports"],f):(n=typeof globalThis!="undefined"?globalThis:n||self,f(n.idmp={}))})(this,function(n){"use strict";const A=()=>{},_=t=>t<0?0:t>6048e5?6048e5:t;n.g={};const o=t=>{t&&delete n.g[t]},l=()=>{n.g={}},u=(t,c,T)=>{const{maxRetry:a=30,maxAge:p=3e3,onBeforeRetry:M=A}=T||{},R=_(p);if(!t)return c();n.g[t]=n.g[t]||{0:0,1:0,4:[]};const e=n.g[t],g=()=>{e[1]=0,e[2]=void 0,e[3]=void 0},r=()=>{for(let s of e[4])s[0](e[2]);setTimeout(()=>{o(t)},R)},h=()=>{for(let s of e[4])s[1](e[3]);o(t)},m=()=>new Promise((s,d)=>{if(!e[5]&&(e[5]=c),e[2]){s(e[2]);return}if(e[3]){d(e[3]);return}e[1]===0?(e[1]=1,e[4].push([s,d]),e[5]().then(i=>{e[1]=4,e[2]=i,r()}).catch(i=>{e[1]=3,e[3]=i,++e[0],e[0]>a?h():(M(i,{globalKey:t,retryCount:e[0]}),g(),setTimeout(m,(e[0]-1)*50))})):e[1]===1?e[4].push([s,d]):e[1]===4?r():e[1]===3&&h()});return m()};u.flush=o,u.flushAll=l,n.default=u,Object.defineProperties(n,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}})}); | ||
(function(n,i){typeof exports=="object"&&typeof module!="undefined"?i(exports):typeof define=="function"&&define.amd?define(["exports"],i):(n=typeof globalThis!="undefined"?globalThis:n||self,i(n.idmp={}))})(this,function(n){"use strict";const A=()=>{},_=t=>t<0?0:t>6048e5?6048e5:t;n.g={};const u=t=>{t&&delete n.g[t]},T=()=>{n.g={}},d=(t,c,a)=>{const{maxRetry:r=30,maxAge:g=3e3,onBeforeRetry:p=A}=a||{},M=_(g);if(!t)return c();n.g[t]=n.g[t]||{0:0,1:0,4:[]};const e=n.g[t],R=()=>{e[1]=0,e[2]=void 0,e[3]=void 0},h=()=>{const f=e[4].length;for(let s=0;s<f;++s)e[4][s][0](e[2]);e[4]=[],setTimeout(()=>{u(t)},M)},l=()=>{const f=e[4].length-r;for(let s=0;s<f;++s)e[4][s][1](e[3]);u(t)},m=()=>new Promise((f,s)=>{if(!e[5]&&(e[5]=c),e[2]){f(e[2]);return}if(e[3]){s(e[3]);return}e[1]===0?(e[1]=1,e[4].push([f,s]),e[5]().then(o=>{e[1]=4,e[2]=o,h()}).catch(o=>{e[1]=3,e[3]=o,++e[0],e[0]>r?l():(p(o,{globalKey:t,retryCount:e[0]}),R(),setTimeout(m,(e[0]-1)*50))})):e[1]===1?e[4].push([f,s]):e[1]===4?h():e[1]===3&&l()});return m()};d.flush=u,d.flushAll=T,n.default=d,Object.defineProperties(n,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}})}); |
@@ -62,7 +62,11 @@ const DEFAULT_MAX_AGE = 3e3; | ||
const doResolves = () => { | ||
for (let item of cache[ | ||
const len = cache[ | ||
4 | ||
/* pendingList */ | ||
]) { | ||
item[0](cache[ | ||
].length; | ||
for (let i = 0; i < len; ++i) { | ||
cache[ | ||
4 | ||
/* pendingList */ | ||
][i][0](cache[ | ||
2 | ||
@@ -72,2 +76,6 @@ /* resData */ | ||
} | ||
cache[ | ||
4 | ||
/* pendingList */ | ||
] = []; | ||
setTimeout(() => { | ||
@@ -78,7 +86,11 @@ flush(globalKey); | ||
const doRejects = () => { | ||
for (let item of cache[ | ||
const len = cache[ | ||
4 | ||
/* pendingList */ | ||
]) { | ||
item[1](cache[ | ||
].length - maxRetry; | ||
for (let i = 0; i < len; ++i) { | ||
cache[ | ||
4 | ||
/* pendingList */ | ||
][i][1](cache[ | ||
3 | ||
@@ -85,0 +97,0 @@ /* resError */ |
@@ -77,7 +77,11 @@ const DEFAULT_MAX_AGE = 3e3; | ||
const doResolves = () => { | ||
for (let item of cache[ | ||
const len = cache[ | ||
4 | ||
/* pendingList */ | ||
]) { | ||
item[0](cache[ | ||
].length; | ||
for (let i = 0; i < len; ++i) { | ||
cache[ | ||
4 | ||
/* pendingList */ | ||
][i][0](cache[ | ||
2 | ||
@@ -87,2 +91,6 @@ /* resData */ | ||
} | ||
cache[ | ||
4 | ||
/* pendingList */ | ||
] = []; | ||
setTimeout(() => { | ||
@@ -93,7 +101,11 @@ flush(globalKey); | ||
const doRejects = () => { | ||
for (let item of cache[ | ||
const len = cache[ | ||
4 | ||
/* pendingList */ | ||
]) { | ||
item[1](cache[ | ||
].length - maxRetry; | ||
for (let i = 0; i < len; ++i) { | ||
cache[ | ||
4 | ||
/* pendingList */ | ||
][i][1](cache[ | ||
3 | ||
@@ -136,5 +148,15 @@ /* resError */ | ||
const arr = stack.split("\n").filter((o) => o.includes(":")); | ||
const idx = arr.findLastIndex( | ||
(o) => o.includes("idmp/") || o.includes("idmp\\") || o.includes("idmp") | ||
); | ||
let idx = Infinity; | ||
for (let key of [ | ||
"idmp/src/index.ts", | ||
"idmp/", | ||
"idmp\\", | ||
"idmp" | ||
]) { | ||
const _idx = arr.findLastIndex((o) => o.includes(key)); | ||
if (_idx > -1) { | ||
idx = _idx; | ||
break; | ||
} | ||
} | ||
const line = arr[idx + 1] || ""; | ||
@@ -156,2 +178,3 @@ return line; | ||
`1.${line1}`, | ||
"------------", | ||
`2.${line2}` | ||
@@ -158,0 +181,0 @@ ].join("\n")}` |
{ | ||
"name": "idmp", | ||
"version": "1.5.2", | ||
"version": "1.6.0", | ||
"keywords": [ | ||
@@ -5,0 +5,0 @@ "cache response", |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
62044
12
1036