Spaces:
Configuration error
Configuration error
Download web/libs/editor/src/lib/AudioUltra/Common/Cacheable.ts from bisalsaha/lebel-studio: direct link, hf CLI and curl.
- Browser
- Download file 533 Bytes
-
https://huggingface.co/spaces/bisalsaha/lebel-studio/resolve/main/web/libs/editor/src/lib/AudioUltra/Common/Cacheable.ts
- Command line
-
hf download hf://spaces/bisalsaha/lebel-studio/web/libs/editor/src/lib/AudioUltra/Common/Cacheable.ts
-
curl -L -o Cacheable.ts https://huggingface.co/spaces/bisalsaha/lebel-studio/resolve/main/web/libs/editor/src/lib/AudioUltra/Common/Cacheable.ts
533 Bytes
| export class Cacheable { | |
| private cache = new Map<string, any>(); | |
| createKey(...args: any[]) { | |
| if (args.length === 1) { | |
| return args[0].toString(); | |
| } | |
| return args.join(":"); | |
| } | |
| clearCache() { | |
| this.cache.clear(); | |
| } | |
| cached(key: number | string | Array<string | number>, fn: () => any) { | |
| const cacheKey = this.createKey(key); | |
| if (this.cache.has(cacheKey)) { | |
| return this.cache.get(cacheKey); | |
| } | |
| const result = fn(); | |
| this.cache.set(cacheKey, result); | |
| return result; | |
| } | |
| } | |