Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

idmp

Package Overview
Dependencies
Maintainers
1
Versions
94
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

idmp - npm Package Compare versions

Comparing version 1.10.0 to 1.11.0

85

dist/index.browser.esm.js

@@ -1,18 +0,25 @@

/*! idmp v1.10.0 | (c) github/haozi | MIT */
const R = () => {
/*! idmp v1.11.0 | (c) github/haozi | MIT */
const l = () => {
};
const E = (e) => e < 0 ? 0 : e > 6048e5 ? 6048e5 : e;
const p = (e) => e < 0 ? 0 : e > 6048e5 ? 6048e5 : e;
let o = {};
const c = (e) => {
const x = (e) => {
const {
maxRetry: r = 30,
maxAge: u = 3e3,
onBeforeRetry: c = l
} = e || {}, i = p(u);
return {
maxRetry: r,
maxAge: i,
onBeforeRetry: c
};
}, d = (e) => {
e && delete o[e];
}, T = () => {
}, E = () => {
o = {};
}, d = (e, f, h) => {
const {
maxRetry: u = 30,
maxAge: A = 3e3,
onBeforeRetry: _ = R
} = h || {}, a = E(A);
}, A = (e, r, u) => {
if (!e)
return f();
return r();
const { maxRetry: c, maxAge: i, onBeforeRetry: a } = x(u);
o[e] = o[e] || {

@@ -23,3 +30,3 @@ 0: 0,

};
const t = o[e], l = () => {
const t = o[e], _ = () => {
t[

@@ -36,11 +43,11 @@ 1

}, m = () => {
const n = t[
const s = t[
4
/* pendingList */
].length;
for (let s = 0; s < n; ++s)
for (let n = 0; n < s; ++n)
t[
4
/* pendingList */
][s][0](t[
][n][0](t[
2

@@ -53,19 +60,19 @@ /* resData */

] = [], setTimeout(() => {
c(e);
}, a);
}, p = () => {
const n = t[
d(e);
}, i);
}, R = () => {
const s = t[
4
/* pendingList */
].length - u;
for (let s = 0; s < n; ++s)
].length - c;
for (let n = 0; n < s; ++n)
t[
4
/* pendingList */
][s][1](t[
][n][1](t[
3
/* resError */
]);
c(e);
}, i = () => new Promise((n, s) => {
d(e);
}, h = () => new Promise((s, n) => {
if (!t[

@@ -77,7 +84,7 @@ 5

/* oneCallPromiseFunc */
] = f), t[
] = r), t[
2
/* resData */
]) {
n(t[
s(t[
2

@@ -97,14 +104,14 @@ /* resData */

/* pendingList */
].push([n, s]), t[
].push([s, n]), t[
5
/* oneCallPromiseFunc */
]().then((r) => {
]().then((f) => {
t[
2
/* resData */
] = r, m(), t[
] = f, m(), t[
1
/* status */
] = 4;
}).catch((r) => {
}).catch((f) => {
t[

@@ -116,3 +123,3 @@ 1

/* resError */
] = r, ++t[
] = f, ++t[
0

@@ -123,3 +130,3 @@ /* retryCount */

/* retryCount */
] > u ? p() : (_(r, {
] > c ? R() : (a(f, {
globalKey: e,

@@ -130,3 +137,3 @@ retryCount: t[

]
}), l(), setTimeout(i, (t[
}), _(), setTimeout(h, (t[
0

@@ -141,11 +148,11 @@ /* retryCount */

/* pendingList */
].push([n, s]);
].push([s, n]);
});
return i();
return h();
};
d.flush = c;
d.flushAll = T;
A.flush = d;
A.flushAll = E;
export {
d as default,
A as default,
o as g
};

@@ -1,2 +0,2 @@

/*! idmp v1.10.0 | (c) github/haozi | MIT */
(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 l=()=>{},m=t=>t<0?0:t>6048e5?6048e5:t;n.g={};const i=t=>{t&&delete n.g[t]},A=()=>{n.g={}},d=(t,c,_)=>{const{maxRetry:r=30,maxAge:T=3e3,onBeforeRetry:a=l}=_||{},g=m(T);if(!t)return c();n.g[t]=n.g[t]||{0:0,1:0,4:[]};const e=n.g[t],p=()=>{e[1]=0,e[2]=void 0,e[3]=void 0},M=()=>{const o=e[4].length;for(let s=0;s<o;++s)e[4][s][0](e[2]);e[4]=[],setTimeout(()=>{i(t)},g)},R=()=>{const o=e[4].length-r;for(let s=0;s<o;++s)e[4][s][1](e[3]);i(t)},h=()=>new Promise((o,s)=>{if(!e[5]&&(e[5]=c),e[2]){o(e[2]);return}e[1]===0?(e[1]=1,e[4].push([o,s]),e[5]().then(u=>{e[2]=u,M(),e[1]=4}).catch(u=>{e[1]=3,e[3]=u,++e[0],e[0]>r?R():(a(u,{globalKey:t,retryCount:e[0]}),p(),setTimeout(h,(e[0]-1)*50))})):e[1]===1&&e[4].push([o,s])});return h()};d.flush=i,d.flushAll=A,n.default=d,Object.defineProperties(n,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}})});
/*! idmp v1.11.0 | (c) github/haozi | MIT */
(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 a=t=>{const{maxRetry:u=30,maxAge:h=3e3,onBeforeRetry:i=A}=t||{},m=_(h);return{maxRetry:u,maxAge:m,onBeforeRetry:i}},d=t=>{t&&delete n.g[t]},g=()=>{n.g={}},r=(t,u,h)=>{if(!t)return u();const{maxRetry:i,maxAge:m,onBeforeRetry:p}=a(h);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},T=()=>{const o=e[4].length;for(let s=0;s<o;++s)e[4][s][0](e[2]);e[4]=[],setTimeout(()=>{d(t)},m)},M=()=>{const o=e[4].length-i;for(let s=0;s<o;++s)e[4][s][1](e[3]);d(t)},l=()=>new Promise((o,s)=>{if(!e[5]&&(e[5]=u),e[2]){o(e[2]);return}e[1]===0?(e[1]=1,e[4].push([o,s]),e[5]().then(c=>{e[2]=c,T(),e[1]=4}).catch(c=>{e[1]=3,e[3]=c,++e[0],e[0]>i?M():(p(c,{globalKey:t,retryCount:e[0]}),R(),setTimeout(l,(e[0]-1)*50))})):e[1]===1&&e[4].push([o,s])});return l()};r.flush=d,r.flushAll=g,n.default=r,Object.defineProperties(n,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}})});

@@ -7,2 +7,4 @@ /**

*/
type IdmpGlobalKey = string | number | symbol | false | null | undefined;
type IdmpPromise<T> = () => Promise<T>;
interface IdmpOptions {

@@ -36,3 +38,2 @@ /**

}
type IdmpPromise<T> = () => Promise<T>;
declare const enum Status {

@@ -63,3 +64,2 @@ UNSENT = 0,

}>;
type IdmpGlobalKey = string | number | symbol | false | null | undefined;
declare const idmp: {

@@ -72,2 +72,2 @@ <T>(globalKey: IdmpGlobalKey, promiseFunc: IdmpPromise<T>, options?: IdmpOptions): Promise<T>;

export default idmp;
export { _globalStore as g, type Idmp, type IdmpGlobalKey, type IdmpOptions, type IdmpPromise };
export { _globalStore as g, type Idmp, type IdmpGlobalKey, type IdmpOptions, type IdmpPromise, };

@@ -1,2 +0,2 @@

/*! idmp v1.10.0 | (c) github/haozi | MIT */
/*! idmp v1.11.0 | (c) github/haozi | MIT */
const DEFAULT_MAX_AGE = 3e3;

@@ -15,2 +15,15 @@ const _7days = 6048e5;

let _globalStore = {};
const getOptions = (options) => {
const {
maxRetry = 30,
maxAge: paramMaxAge = DEFAULT_MAX_AGE,
onBeforeRetry = noop
} = options || {};
const maxAge = getRange(paramMaxAge);
return {
maxRetry,
maxAge,
onBeforeRetry
};
};
const flush = (globalKey) => {

@@ -25,11 +38,6 @@ if (!globalKey)

const idmp = (globalKey, promiseFunc, options) => {
const {
maxRetry = 30,
maxAge: paramMaxAge = DEFAULT_MAX_AGE,
onBeforeRetry = noop
} = options || {};
const maxAge = getRange(paramMaxAge);
if (!globalKey) {
return promiseFunc();
}
const { maxRetry, maxAge, onBeforeRetry } = getOptions(options);
_globalStore[globalKey] = _globalStore[globalKey] || {

@@ -36,0 +44,0 @@ [

@@ -1,2 +0,2 @@

/*! idmp v1.10.0 | (c) github/haozi | MIT */
/*! idmp v1.11.0 | (c) github/haozi | MIT */
const DEFAULT_MAX_AGE = 3e3;

@@ -37,2 +37,15 @@ const _7days = 6048e5;

let _globalStore = {};
const getOptions = (options) => {
const {
maxRetry = 30,
maxAge: paramMaxAge = DEFAULT_MAX_AGE,
onBeforeRetry = noop
} = options || {};
const maxAge = getRange(paramMaxAge);
return {
maxRetry,
maxAge,
onBeforeRetry
};
};
const flush = (globalKey) => {

@@ -50,11 +63,6 @@ if (!globalKey)

}
const {
maxRetry = 30,
maxAge: paramMaxAge = DEFAULT_MAX_AGE,
onBeforeRetry = noop
} = options || {};
const maxAge = getRange(paramMaxAge);
if (!globalKey) {
return promiseFunc();
}
const { maxRetry, maxAge, onBeforeRetry } = getOptions(options);
_globalStore[globalKey] = _globalStore[globalKey] || {

@@ -61,0 +69,0 @@ [

{
"name": "idmp",
"version": "1.10.0",
"version": "1.11.0",
"keywords": [

@@ -5,0 +5,0 @@ "cache response",

@@ -84,6 +84,6 @@ # idmp

| Property | Type | Default | Description |
| --------------- | ---------- | ------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| `maxRetry` | `number` | `30` | Maximum number of retry attempts. |
| `maxAge` | `number` | `3000` | Maximum age in milliseconds. The maximum value is 604800000ms (7 days). |
| Property | Type | Default | Description |
| --------------- | ---------- | ------- | --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| `maxRetry` | `number` | `30` | Maximum number of retry attempts. |
| `maxAge` | `number` | `3000` | Maximum age in milliseconds. The maximum value is 604800000ms (7 days). |
| `onBeforeRetry` | `function` | - | Function to be executed before a retry attempt. Takes two parameters: `err` (any type) and `extra` (an object with properties `globalKey` of type `IdmpGlobalKey` and `retryCount` of type `number`). Returns `void`. |

@@ -90,0 +90,0 @@

@@ -84,6 +84,6 @@ # idmp

| Property | Type | Default | Description |
| --------------- | ---------- | ------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| `maxRetry` | `number` | `30` | Maximum number of retry attempts. |
| `maxAge` | `number` | `3000` | Maximum age in milliseconds. The maximum value is 604800000ms (7 days). |
| Property | Type | Default | Description |
| --------------- | ---------- | ------- | --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| `maxRetry` | `number` | `30` | Maximum number of retry attempts. |
| `maxAge` | `number` | `3000` | Maximum age in milliseconds. The maximum value is 604800000ms (7 days). |
| `onBeforeRetry` | `function` | - | Function to be executed before a retry attempt. Takes two parameters: `err` (any type) and `extra` (an object with properties `globalKey` of type `IdmpGlobalKey` and `retryCount` of type `number`). Returns `void`. |

@@ -90,0 +90,0 @@

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc