Make _.memoize skip the __proto__ key.

This commit is contained in:
John-David Dalton
2014-05-07 00:40:27 -07:00
parent 32167b45ce
commit 43c13c22a8
2 changed files with 28 additions and 16 deletions

View File

@@ -5340,9 +5340,11 @@
throw new TypeError(funcErrorText);
}
var memoized = function() {
var cache = memoized.cache,
key = resolver ? resolver.apply(this, arguments) : '_' + arguments[0];
var key = resolver ? resolver.apply(this, arguments) : arguments[0];
if (key == '__proto__') {
return func.apply(this, arguments);
}
var cache = memoized.cache;
return hasOwnProperty.call(cache, key)
? cache[key]
: (cache[key] = func.apply(this, arguments));