Skip to content

Commit

Permalink
Generalize unaryMemoize to efficiently support undefined results
Browse files Browse the repository at this point in the history
  • Loading branch information
gibson042 authored Jul 12, 2023
1 parent c1c31de commit 59e3e38
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion src/emitter.ts
Original file line number Diff line number Diff line change
Expand Up @@ -185,7 +185,7 @@ function unaryMemoize<K, V>(fn: (arg: K) => V, prepopulate: K[] = []) {
const cache = new Map(prepopulate.map(arg => [arg, fn(arg)]));
return (arg: K) => {
let value = cache.get(arg);
if (!value) {
if (value === undefined && !cache.has(arg)) {
value = fn(arg);
cache.set(arg, value);
}
Expand Down

0 comments on commit 59e3e38

Please sign in to comment.