control.js
function memoize(fn) {
  const dataProp = '__data__.string.__data__',
    memFn = _.memoize.apply(_, _.slice(arguments)),
    report = _.throttle(reportMemoryLeak, minute),
    controlFn = function () {
      const result = memFn.apply(null, _.slice(arguments));

      if (_.size(_.get(memFn, `cache.${dataProp}`)) >= memoryLeakThreshold) {
        report(fn, _.get(memFn, `cache.${dataProp}`));
      }

      return result;
    };

  Object.defineProperty(controlFn, 'cache', defineWritable({
    get() { return memFn.cache; },
    set(value) { memFn.cache = value; }
  }));

  return controlFn;
}
function memoize(fn) {
  const dataProp = '__data__.string.__data__',
    memFn = _.memoize.apply(_, _.slice(arguments)),
    report = _.throttle(reportMemoryLeak, minute),
    controlFn = function () {
      const result = memFn.apply(null, _.slice(arguments));

      if (_.size(_.get(memFn, `cache.${dataProp}`)) >= memoryLeakThreshold) {
        report(fn, _.get(memFn, `cache.${dataProp}`));
      }

      return result;
    };

  Object.defineProperty(controlFn, 'cache', defineWritable({
    get() { return memFn.cache; },
    set(value) { memFn.cache = value; }
  }));

  return controlFn;
}
function memoize ( fn ) { const dataProp = '__data__.string.__data__' , memFn = _ . memoize . apply ( _ , _ . slice ( arguments ) ) , report = _ . throttle ( reportMemoryLeak , minute ) , controlFn = function ( ) { const result = memFn . apply ( null , _ . slice ( arguments ) ) ; if ( _ . size ( _ . get ( memFn , ` ${ dataProp } ` ) ) >= memoryLeakThreshold ) { report ( fn , _ . get ( memFn , ` ${ dataProp } ` ) ) ; } return result ; } ; Object . defineProperty ( controlFn , 'cache' , defineWritable ( { get ( ) { return memFn . cache ; } , set ( value ) { memFn . cache = value ; } } ) ) ; return controlFn ; }
Memoize, but warn if the target is not suitable for memoization
@param {function} fn
@returns {function}
Memoize but warn if the target is not suitable for memoization