cache.ts 269 B

1234567891011
  1. import { LRUCache } from 'lru-cache'
  2. export function createCache<T extends {}>(
  3. max = 500,
  4. ): Map<string, T> | LRUCache<string, T> {
  5. /* v8 ignore next 3 */
  6. if (__GLOBAL__ || __ESM_BROWSER__) {
  7. return new Map<string, T>()
  8. }
  9. return new LRUCache({ max })
  10. }