1 var memoize = require('./memoize');
3 /** Used as the maximum memoize cache size. */
4 var MAX_MEMOIZE_SIZE = 500;
7 * A specialized version of `_.memoize` which clears the memoized function's
8 * cache when it exceeds `MAX_MEMOIZE_SIZE`.
11 * @param {Function} func The function to have its output memoized.
12 * @returns {Function} Returns the new memoized function.
14 function memoizeCapped(func) {
15 var result = memoize(func, function(key) {
16 if (cache.size === MAX_MEMOIZE_SIZE) {
22 var cache = result.cache;
26 module.exports = memoizeCapped;