Update vendor/underscore.

Former-commit-id: 5ede87579d9b7a8e505da23fc3a4531be40a151b
This commit is contained in:
John-David Dalton
2012-10-13 00:01:29 -07:00
parent bda00bf512
commit 10c87012be
3 changed files with 12 additions and 7 deletions

View File

@@ -171,6 +171,14 @@ $(document).ready(function() {
test('reject', function() { test('reject', function() {
var odds = _.reject([1, 2, 3, 4, 5, 6], function(num){ return num % 2 == 0; }); var odds = _.reject([1, 2, 3, 4, 5, 6], function(num){ return num % 2 == 0; });
equal(odds.join(', '), '1, 3, 5', 'rejected each even number'); equal(odds.join(', '), '1, 3, 5', 'rejected each even number');
var context = "obj";
var evens = _.reject([1, 2, 3, 4, 5, 6], function(num){
equal(context, "obj");
return num % 2 != 0;
}, context);
equal(evens.join(', '), '2, 4, 6', 'rejected each odd number');
}); });
test('all', function() { test('all', function() {

File diff suppressed because one or more lines are too long

View File

@@ -177,12 +177,9 @@
// Return all the elements for which a truth test fails. // Return all the elements for which a truth test fails.
_.reject = function(obj, iterator, context) { _.reject = function(obj, iterator, context) {
var results = []; return _.filter(obj, function(value, index, list) {
if (obj == null) return results; return !iterator.call(context, value, index, list);
each(obj, function(value, index, list) { }, context);
if (!iterator.call(context, value, index, list)) results[results.length] = value;
});
return results;
}; };
// Determine whether all of the elements match a truth test. // Determine whether all of the elements match a truth test.