sindresorhus/memoize

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

Open

#90 ouverte le 1 févr. 2023

Voir sur GitHub
 (6 commentaires) (0 réactions) (0 assignés)TypeScript (55 forks)user submission
enhancementhelp wanted

Métriques du dépôt

Stars
 (1 155 stars)
Métriques de merge PR
 (Aucune PR mergée en 30 j)

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

Guide contributeur