sindresorhus/memoize

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

Open

#90 aperta il 1 feb 2023

Vedi su GitHub
 (6 commenti) (0 reazioni) (0 assegnatari)TypeScript (55 fork)user submission
enhancementhelp wanted

Metriche repository

Star
 (1155 star)
Metriche merge PR
 (Nessuna PR mergiata in 30 g)

Descrizione

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
})

Guida contributor