mirror of
https://github.com/whoisclebs/lodash.git
synced 2026-01-31 15:27:50 +00:00
bug fix for _.memoize when key is derived from prototype
This commit is contained in:
@@ -52,6 +52,13 @@ $(document).ready(function() {
|
||||
var fastFib = _.memoize(fib);
|
||||
equals(fib(10), 55, 'a memoized version of fibonacci produces identical results');
|
||||
equals(fastFib(10), 55, 'a memoized version of fibonacci produces identical results');
|
||||
|
||||
var o = function(str) {
|
||||
return str;
|
||||
};
|
||||
var fastO = _.memoize(o);
|
||||
equals(o('toString'), 'toString', 'checks hasOwnProperty');
|
||||
equals(fastO('toString'), 'toString', 'checks hasOwnProperty');
|
||||
});
|
||||
|
||||
asyncTest("functions: delay", 2, function() {
|
||||
|
||||
@@ -426,7 +426,7 @@
|
||||
hasher = hasher || _.identity;
|
||||
return function() {
|
||||
var key = hasher.apply(this, arguments);
|
||||
return key in memo ? memo[key] : (memo[key] = func.apply(this, arguments));
|
||||
return hasOwnProperty.call(memo, key) ? memo[key] : (memo[key] = func.apply(this, arguments));
|
||||
};
|
||||
};
|
||||
|
||||
|
||||
Reference in New Issue
Block a user