mirror of
https://github.com/th-ch/youtube-music.git
synced 2026-01-14 03:41:46 +00:00
fix(cache): use cacheNoArgs for better performance
This commit is contained in:
@ -40,6 +40,16 @@ export function cache<T extends (...params: P) => R, P extends never[], R>(
|
||||
}) as T;
|
||||
}
|
||||
|
||||
export function cacheNoArgs<R>(fn: () => R): () => R {
|
||||
let cached: R;
|
||||
return () => {
|
||||
if (cached === undefined) {
|
||||
cached = fn();
|
||||
}
|
||||
return cached;
|
||||
};
|
||||
}
|
||||
|
||||
/*
|
||||
The following are currently unused, but potentially useful in the future
|
||||
*/
|
||||
|
||||
Reference in New Issue
Block a user