Permalink
Browse files

Update docs and builds.

  • Loading branch information...
1 parent 68fcc30 commit aeba0a69cbc7f135cff1f66cb9d9e413cbab384f @jdalton jdalton committed Apr 2, 2013
View
@@ -18,9 +18,9 @@
/** Detect free variable `module` */
var freeModule = typeof module == 'object' && module && module.exports == freeExports && module;
- /** Detect free variable `global` and use it as `window` */
+ /** Detect free variable `global`, from Node.js or Browserified code, and use it as `window` */
var freeGlobal = typeof global == 'object' && global;
- if (freeGlobal.global === freeGlobal) {
+ if (freeGlobal.global === freeGlobal || freeGlobal.window === freeGlobal) {
window = freeGlobal;
}
@@ -30,6 +30,9 @@
/** Used internally to indicate various things */
var indicatorObject = {};
+ /** Used to prefix keys to avoid issues with `__proto__` and properties on `Object.prototype` */
+ var keyPrefix = +new Date + '';
+
/** Used to match empty string literals in compiled template source */
var reEmptyStringLeading = /\b__p \+= '';/g,
reEmptyStringMiddle = /\b(__p \+=) '' \+/g,
@@ -122,7 +125,7 @@
toString = objectRef.toString;
/* Native method shortcuts for methods with the same name as other `lodash` methods */
- var nativeBind = reNative.test(nativeBind = slice.bind) && nativeBind,
+ var nativeBind = reNative.test(nativeBind = toString.bind) && nativeBind,
nativeIsArray = reNative.test(nativeIsArray = Array.isArray) && nativeIsArray,
nativeIsFinite = window.isFinite,
nativeIsNaN = window.isNaN,

Some generated files are not rendered by default. Learn more.

Oops, something went wrong.
View
@@ -18,9 +18,9 @@
/** Detect free variable `module` */
var freeModule = typeof module == 'object' && module && module.exports == freeExports && module;
- /** Detect free variable `global` and use it as `window` */
+ /** Detect free variable `global`, from Node.js or Browserified code, and use it as `window` */
var freeGlobal = typeof global == 'object' && global;
- if (freeGlobal.global === freeGlobal) {
+ if (freeGlobal.global === freeGlobal || freeGlobal.window === freeGlobal) {
window = freeGlobal;
}
@@ -30,6 +30,9 @@
/** Used internally to indicate various things */
var indicatorObject = {};
+ /** Used to prefix keys to avoid issues with `__proto__` and properties on `Object.prototype` */
+ var keyPrefix = +new Date + '';
+
/** Used to match empty string literals in compiled template source */
var reEmptyStringLeading = /\b__p \+= '';/g,
reEmptyStringMiddle = /\b(__p \+=) '' \+/g,
@@ -175,7 +178,7 @@
toString = objectRef.toString;
/* Native method shortcuts for methods with the same name as other `lodash` methods */
- var nativeBind = reNative.test(nativeBind = slice.bind) && nativeBind,
+ var nativeBind = reNative.test(nativeBind = toString.bind) && nativeBind,
nativeIsArray = reNative.test(nativeIsArray = Array.isArray) && nativeIsArray,
nativeIsFinite = context.isFinite,
nativeIsNaN = context.isNaN,
@@ -579,16 +582,14 @@
index = fromIndex - 1;
while (++index < length) {
- // manually coerce `value` to a string because `hasOwnProperty`, in some
- // older versions of Firefox, coerces objects incorrectly
- var key = String(array[index]);
- (hasOwnProperty.call(cache, key) ? cache[key] : (cache[key] = [])).push(array[index]);
+ var key = keyPrefix + array[index];
+ (cache[key] || (cache[key] = [])).push(array[index]);
}
}
return function(value) {
if (isLarge) {
- var key = String(value);
- return hasOwnProperty.call(cache, key) && indexOf(cache[key], value) > -1;
+ var key = keyPrefix + value;
+ return cache[key] && indexOf(cache[key], value) > -1;
}
return indexOf(array, value, fromIndex) > -1;
}
@@ -2030,9 +2031,10 @@
? (isArray(value) ? value : [])
: (isPlainObject(value) ? value : {});
+ var isShallow;
if (callback) {
result = callback(value, source);
- if (typeof result != 'undefined') {
+ if ((isShallow = typeof result != 'undefined')) {
value = result;
}
}
@@ -2041,7 +2043,7 @@
stackB.push(value);
// recursively merge objects and arrays (susceptible to call stack limits)
- if (!callback) {
+ if (!isShallow) {
value = merge(value, source, indicatorObject, callback, stackA, stackB);
}
}
@@ -3613,8 +3615,8 @@
while (++index < length) {
var value = array[index];
if (isLarge) {
- var key = String(value);
- var inited = hasOwnProperty.call(cache[0], key)
+ var key = keyPrefix + value;
+ var inited = cache[0][key]
? !(seen = cache[0][key])
: (seen = cache[0][key] = []);
}
@@ -4021,8 +4023,8 @@
computed = callback ? callback(value, index, array) : value;
if (isLarge) {
- var key = String(computed);
- var inited = hasOwnProperty.call(cache, key)
+ var key = keyPrefix + computed;
+ var inited = cache[key]
? !(seen = cache[key])
: (seen = cache[key] = []);
}
@@ -4507,7 +4509,7 @@
function memoize(func, resolver) {
var cache = {};
return function() {
- var key = String(resolver ? resolver.apply(this, arguments) : arguments[0]);
+ var key = keyPrefix + (resolver ? resolver.apply(this, arguments) : arguments[0]);
return hasOwnProperty.call(cache, key)
? cache[key]
: (cache[key] = func.apply(this, arguments));
Oops, something went wrong.

0 comments on commit aeba0a6

Please sign in to comment.