暂无描述

1234567891011121314151617
  1. define(['./_has'], function (_has) {
  2. // Memoize an expensive function by storing its results.
  3. function memoize(func, hasher) {
  4. var memoize = function(key) {
  5. var cache = memoize.cache;
  6. var address = '' + (hasher ? hasher.apply(this, arguments) : key);
  7. if (!_has(cache, address)) cache[address] = func.apply(this, arguments);
  8. return cache[address];
  9. };
  10. memoize.cache = {};
  11. return memoize;
  12. }
  13. return memoize;
  14. });