You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

memoize.js 275 B

3 years ago
1234567891011121314151617
  1. "use strict";
  2. Object.defineProperty(exports, "__esModule", {
  3. value: true
  4. });
  5. exports.default = memoize;
  6. function memoize(fn) {
  7. var cache = {};
  8. return function (arg) {
  9. if (cache[arg] === undefined) {
  10. cache[arg] = fn(arg);
  11. }
  12. return cache[arg];
  13. };
  14. }