Update vendor/underscore.

Former-commit-id: 3e8a169e8cb81fd852e41420ad317ee12ae486f9
This commit is contained in:
John-David Dalton
2012-11-11 20:00:48 -08:00
parent f6d28a90e3
commit 255211cd07
3 changed files with 8 additions and 6 deletions

View File

@@ -268,6 +268,7 @@ $(document).ready(function() {
equal(-Infinity, _.max({}), 'Maximum value of an empty object');
equal(-Infinity, _.max([]), 'Maximum value of an empty array');
equal(_.max({'a': 'a'}), -Infinity, 'Maximum value of a non-numeric collection');
equal(299999, _.max(_.range(1,300000)), "Maximum value of a too-big array");
});
@@ -280,6 +281,7 @@ $(document).ready(function() {
equal(Infinity, _.min({}), 'Minimum value of an empty object');
equal(Infinity, _.min([]), 'Minimum value of an empty array');
equal(_.min({'a': 'a'}), Infinity, 'Minimum value of a non-numeric collection');
var now = new Date(9999999999);
var then = new Date(0);

File diff suppressed because one or more lines are too long

View File

@@ -61,7 +61,7 @@
}
exports._ = _;
} else {
root['_'] = _;
root._ = _;
}
// Current version.
@@ -130,7 +130,7 @@
if (obj == null) obj = [];
if (nativeReduceRight && obj.reduceRight === nativeReduceRight) {
if (context) iterator = _.bind(iterator, context);
return arguments.length > 2 ? obj.reduceRight(iterator, memo) : obj.reduceRight(iterator);
return initial ? obj.reduceRight(iterator, memo) : obj.reduceRight(iterator);
}
var length = obj.length;
if (length !== +length) {
@@ -239,7 +239,7 @@
if (_.isEmpty(attrs)) return [];
return _.filter(obj, function(value) {
for (var key in attrs) {
if (attrs[key] !== value[key]) return false;
if (_.has(attrs, key) && attrs[key] !== value[key]) return false;
}
return true;
});
@@ -253,7 +253,7 @@
return Math.max.apply(Math, obj);
}
if (!iterator && _.isEmpty(obj)) return -Infinity;
var result = {computed : -Infinity};
var result = {computed : -Infinity, value: -Infinity};
each(obj, function(value, index, list) {
var computed = iterator ? iterator.call(context, value, index, list) : value;
computed >= result.computed && (result = {value : value, computed : computed});
@@ -267,7 +267,7 @@
return Math.min.apply(Math, obj);
}
if (!iterator && _.isEmpty(obj)) return Infinity;
var result = {computed : Infinity};
var result = {computed : Infinity, value: Infinity};
each(obj, function(value, index, list) {
var computed = iterator ? iterator.call(context, value, index, list) : value;
computed < result.computed && (result = {value : value, computed : computed});