sindresorhus/memoize

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

Aberta

#90 aberto em 1 de fev. de 2023

 (6 comentários) (0 reação) (0 responsável)TypeScript (55 forks)user submission
enhancementhelp wanted

Métricas do repositório

Stars
 (1.155 estrelas)
Métricas de merge de PR
 (Nenhuma PRs mesclada em 30d)

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