Skip to content

Commit

Permalink
Fix jashkenas#1171 - Simplify some/any.
Browse files Browse the repository at this point in the history
  • Loading branch information
braddunbar committed Jun 28, 2013
1 parent 8597c03 commit 9621217
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 5 deletions.
5 changes: 1 addition & 4 deletions test/collections.js
Original file line number Diff line number Diff line change
Expand Up @@ -197,8 +197,6 @@ $(document).ready(function() {
});

test('any', function() {
var nativeSome = Array.prototype.some;
Array.prototype.some = null;
ok(!_.any([]), 'the empty set');
ok(!_.any([false, false, false]), 'all false values');
ok(_.any([false, false, true]), 'one true value');
Expand All @@ -209,7 +207,6 @@ $(document).ready(function() {
ok(_.any([1], _.identity) === true, 'cast to boolean - true');
ok(_.any([0], _.identity) === false, 'cast to boolean - false');
ok(_.some([false, false, true]), 'aliased as "some"');
Array.prototype.some = nativeSome;
});

test('include', function() {
Expand Down Expand Up @@ -261,7 +258,7 @@ $(document).ready(function() {
result = _.where(list, {b: 2});
equal(result.length, 2);
equal(result[0].a, 1);

result = _.where(list, {a: 1}, true);
equal(result.b, 2, "Only get the first object matched.")
result = _.where(list, {a: 1}, false);
Expand Down
2 changes: 1 addition & 1 deletion underscore.js
Original file line number Diff line number Diff line change
Expand Up @@ -208,7 +208,7 @@
if (obj == null) return result;
if (nativeSome && obj.some === nativeSome) return obj.some(iterator, context);
each(obj, function(value, index, list) {
if (result || (result = iterator.call(context, value, index, list))) return breaker;
if (result = iterator.call(context, value, index, list)) return breaker;
});
return !!result;
};
Expand Down

0 comments on commit 9621217

Please sign in to comment.