feat(dm-stats): add most used words stat
This commit is contained in:
parent
8451a484ff
commit
d21f7fa335
7 changed files with 163 additions and 40 deletions
|
@ -82,13 +82,13 @@ class LocalStorageCacheAdapter {
|
|||
|
||||
const cache = new LocalStorageCacheAdapter();
|
||||
|
||||
export const cached = <T, R, TT>(fn: (...args: T[]) => R, self?: ThisType<TT>): ((...args: T[]) => R) => {
|
||||
export const cached = <T extends unknown[], R, TT>(fn: (...args: T) => R, self?: ThisType<TT>): ((...args: T) => R) => {
|
||||
const cacheName = hashString(fn.toString()).toString();
|
||||
|
||||
// important to return a promise on follow-up calls even if the data is immediately available
|
||||
let isPromise: boolean;
|
||||
|
||||
return (...args: T[]) => {
|
||||
return (...args: T) => {
|
||||
const cacheKey = JSON.stringify(args);
|
||||
|
||||
const cachedValue = cache.get<R>(cacheName, cacheKey);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue