Skip to content

Commit 59e3e38

Browse files
authored
Generalize unaryMemoize to efficiently support undefined results
1 parent c1c31de commit 59e3e38

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

src/emitter.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -185,7 +185,7 @@ function unaryMemoize<K, V>(fn: (arg: K) => V, prepopulate: K[] = []) {
185185
const cache = new Map(prepopulate.map(arg => [arg, fn(arg)]));
186186
return (arg: K) => {
187187
let value = cache.get(arg);
188-
if (!value) {
188+
if (value === undefined && !cache.has(arg)) {
189189
value = fn(arg);
190190
cache.set(arg, value);
191191
}

0 commit comments

Comments
 (0)