sindresorhus/memoize

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

Open

#90 geöffnet am 1. Feb. 2023

Auf GitHub ansehen
 (6 Kommentare) (0 Reaktionen) (0 zugewiesene Personen)TypeScript (1.155 Stars) (55 Forks)user submission
enhancementhelp wanted

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