mirror of
https://github.com/bitwarden/browser.git
synced 2024-11-06 09:20:43 +01:00
sequentialize fixes
This commit is contained in:
parent
003c730eb1
commit
8e586437e0
@ -21,15 +21,15 @@ export function sequentialize(key: (args: any[]) => string = JSON.stringify) {
|
|||||||
};
|
};
|
||||||
|
|
||||||
return {
|
return {
|
||||||
value: (...args: any[]) => {
|
value: function(...args: any[]) {
|
||||||
const argsKey = key(args);
|
const argsKey = key(args);
|
||||||
const cache = getCache(this);
|
const cache = getCache(this);
|
||||||
let res = cache.get(argsKey);
|
let response = cache.get(argsKey);
|
||||||
if (res != null) {
|
if (response != null) {
|
||||||
return res;
|
return response;
|
||||||
}
|
}
|
||||||
|
|
||||||
res = originalMethod.apply(this, args).then((val: any) => {
|
response = originalMethod.apply(this, args).then((val: any) => {
|
||||||
cache.delete(argsKey);
|
cache.delete(argsKey);
|
||||||
return val;
|
return val;
|
||||||
}).catch((err: any) => {
|
}).catch((err: any) => {
|
||||||
@ -37,8 +37,8 @@ export function sequentialize(key: (args: any[]) => string = JSON.stringify) {
|
|||||||
throw err;
|
throw err;
|
||||||
});
|
});
|
||||||
|
|
||||||
cache.set(argsKey, res);
|
cache.set(argsKey, response);
|
||||||
return res;
|
return response;
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
Loading…
Reference in New Issue
Block a user