Update vendor/underscore to v1.5.0.

Former-commit-id: 8f647bccfdd8fe81473ae7d1354056a928b6f28c
This commit is contained in:
John-David Dalton
2013-07-06 18:33:44 -07:00
parent fca2fe2c8a
commit 7d8571b0e1
8 changed files with 162 additions and 47 deletions

View File

@@ -17,15 +17,15 @@ $(document).ready(function() {
hash[l]++;
return hash;
}, {}).value();
ok(counts['a'] == 16 && counts['e'] == 10, 'counted all the letters in the song');
ok(counts.a == 16 && counts.e == 10, 'counted all the letters in the song');
});
test("select/reject/sortBy", function() {
var numbers = [1,2,3,4,5,6,7,8,9,10];
numbers = _(numbers).chain().select(function(n) {
return n % 2 == 0;
return n % 2 === 0;
}).reject(function(n) {
return n % 4 == 0;
return n % 4 === 0;
}).sortBy(function(n) {
return -n;
}).value();
@@ -35,9 +35,9 @@ $(document).ready(function() {
test("select/reject/sortBy in functional style", function() {
var numbers = [1,2,3,4,5,6,7,8,9,10];
numbers = _.chain(numbers).select(function(n) {
return n % 2 == 0;
return n % 2 === 0;
}).reject(function(n) {
return n % 4 == 0;
return n % 4 === 0;
}).sortBy(function(n) {
return -n;
}).value();
@@ -56,4 +56,10 @@ $(document).ready(function() {
equal(numbers.join(', '), "34, 10, 8, 6, 4, 2, 10, 10", 'can chain together array functions.');
});
test("chaining works in small stages", function() {
var o = _([1, 2, 3, 4]).chain();
deepEqual(o.filter(function(i) { return i < 3; }).value(), [1, 2]);
deepEqual(o.filter(function(i) { return i > 2; }).value(), [3, 4]);
});
});