underscore-source 1.0.3 → 1.0.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -55,7 +55,7 @@
|
|
55
55
|
root._ = _;
|
56
56
|
|
57
57
|
// Current version.
|
58
|
-
_.VERSION = '1.0.
|
58
|
+
_.VERSION = '1.0.4';
|
59
59
|
|
60
60
|
// ------------------------ Collection Functions: ---------------------------
|
61
61
|
|
@@ -375,6 +375,16 @@
|
|
375
375
|
return obj;
|
376
376
|
};
|
377
377
|
|
378
|
+
// Memoize an expensive function by storing its results.
|
379
|
+
_.memoize = function(func, hasher) {
|
380
|
+
var memo = {};
|
381
|
+
hasher = hasher || _.identity;
|
382
|
+
return function() {
|
383
|
+
var key = hasher.apply(this, arguments);
|
384
|
+
return key in memo ? memo[key] : (memo[key] = func.apply(this, arguments));
|
385
|
+
};
|
386
|
+
};
|
387
|
+
|
378
388
|
// Delays a function for the given number of milliseconds, and then calls
|
379
389
|
// it with the arguments supplied.
|
380
390
|
_.delay = function(func, wait) {
|