sindresorhus/memoize

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

開放

#90 建立於 2023年2月1日

 (6 則留言) (0 個反應) (0 位負責人)TypeScript (55 個分叉)user submission
enhancementhelp wanted

倉庫指標

星標
 (1,155 顆星)
PR 合併指標
 (30 天內沒有已合併 PR)

描述

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

貢獻者指南