sindresorhus/memoize

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

Open

#90 aberto em 1 de fev. de 2023

Ver no GitHub
 (6 comments) (0 reactions) (0 assignees)TypeScript (1.155 stars) (55 forks)user submission
enhancementhelp wanted

Description

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

Guia do colaborador