mirror of
https://github.com/Rushilwiz/spaceout.git
synced 2025-04-22 12:29:50 -04:00
10 lines
182 B
JavaScript
10 lines
182 B
JavaScript
export default function memoize(fn) {
|
|
var cache = {};
|
|
return function (arg) {
|
|
if (cache[arg] === undefined) {
|
|
cache[arg] = fn(arg);
|
|
}
|
|
|
|
return cache[arg];
|
|
};
|
|
} |