Skip to content

Commit f605905

Browse files
committed
closure
1 parent b46136d commit f605905

1 file changed

Lines changed: 2 additions & 3 deletions

File tree

src/closure.js

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -56,9 +56,8 @@ const cacheFunction = (cb) => {
5656
// `cb` should only ever be invoked once for a given set of arguments.
5757
const cache = {};
5858
return (squared) => {
59-
if (!(squared in cache)) {
60-
return cache[squared] = cb[squared];
61-
}
59+
if (squared in cache) return cache[squared];
60+
cache[squared] = cb(squared);
6261
return cache[squared];
6362
};
6463
};

0 commit comments

Comments
 (0)