sindresorhus/memoize

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

Open

#90 建立於 2023年2月1日

在 GitHub 查看
 (6 留言) (0 反應) (0 負責人)TypeScript (1,155 star) (55 fork)user submission
enhancementhelp wanted

描述

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

貢獻者指南