mirror of
https://github.com/whoisclebs/lodash.git
synced 2026-02-03 08:37:49 +00:00
Underscore 1.0.4, with _.memoize
This commit is contained in:
@@ -55,7 +55,7 @@
|
||||
root._ = _;
|
||||
|
||||
// Current version.
|
||||
_.VERSION = '1.0.3';
|
||||
_.VERSION = '1.0.4';
|
||||
|
||||
// ------------------------ Collection Functions: ---------------------------
|
||||
|
||||
@@ -375,6 +375,16 @@
|
||||
return obj;
|
||||
};
|
||||
|
||||
// Memoize an expensive function by storing its results.
|
||||
_.memoize = function(func, hasher) {
|
||||
var memo = {};
|
||||
hasher = hasher || _.identity;
|
||||
return function() {
|
||||
var key = hasher.apply(this, arguments);
|
||||
return key in memo ? memo[key] : (memo[key] = func.apply(this, arguments));
|
||||
};
|
||||
};
|
||||
|
||||
// Delays a function for the given number of milliseconds, and then calls
|
||||
// it with the arguments supplied.
|
||||
_.delay = function(func, wait) {
|
||||
|
||||
Reference in New Issue
Block a user