Skip to content

Instantly share code, notes, and snippets.

@robozevel
Created February 2, 2014 20:19
Show Gist options
  • Save robozevel/8774258 to your computer and use it in GitHub Desktop.
Save robozevel/8774258 to your computer and use it in GitHub Desktop.
Execute function not more than once every X milliseconds, otherwise return cached result.
_.mixin({
cacheFor: function(wait, fn) {
return _.throttle(fn, wait, { trailing: false });
}
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment