sindresorhus/memoize

Warn when `cacheKey` is unset and `function.length > 1`?

Offen

#90 geöffnet am 01.02.2023

 (6 Kommentare) (0 Reaktionen) (0 zugewiesene Personen)TypeScript (55 Forks)user submission
enhancementhelp wanted

Repository-Metriken

Stars
 (1.155 Sterne)
PR-Merge-Metriken
 (Keine gemergten PRs in 30 T)

Beschreibung

By default, only the memoized function's first argument is considered via strict equality comparison

I think mem should call console.warn in this case:

mem(async (host, path) => fetch(host + path))

Correct usage:

mem(async (host, path) => fetch(host + path), {
  cacheKey: args => args.join()
})
mem(async (host, path) => fetch(host + path), {
  cacheKey: JSON.stringify
})

Contributor Guide