Skip to content

Instantly share code, notes, and snippets.

@feng92f
Created August 19, 2012 08:49
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save feng92f/3393773 to your computer and use it in GitHub Desktop.
Save feng92f/3393773 to your computer and use it in GitHub Desktop.
js snippt
hasher || (hasher = _.identity);
_.memoize = function(func, hasher) {
var memo = {};
hasher || (hasher = _.identity);
return function() {
var key = hasher.apply(this, arguments);//Good
return _.has(memo, key) ? memo[key] : (memo[key] = func.apply(this, arguments));
};
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment