From 74d282ccc82fe9dfb340aaeef22c3d656f2e2ad4 Mon Sep 17 00:00:00 2001 From: Jeremy Ashkenas Date: Fri, 15 Oct 2010 17:15:26 -0400 Subject: [PATCH] fixing mistakenly-aliased contains ... should refer to include. --- test/collections.js | 2 +- underscore.js | 7 ++++--- 2 files changed, 5 insertions(+), 4 deletions(-) diff --git a/test/collections.js b/test/collections.js index 9c72e889e..4e7c7ab6b 100644 --- a/test/collections.js +++ b/test/collections.js @@ -111,7 +111,7 @@ $(document).ready(function() { test('collections: include', function() { ok(_.include([1,2,3], 2), 'two is in the array'); ok(!_.include([1,3,9], 2), 'two is not in the array'); - ok(_.contains({moe:1, larry:3, curly:9}, 3), '_.include on objects checks their values'); + ok(_.contains({moe:1, larry:3, curly:9}, 3) === true, '_.include on objects checks their values'); ok(_([1,2,3]).include(2), 'OO-style include'); }); diff --git a/underscore.js b/underscore.js index 2227dcf5e..6ca732b20 100644 --- a/underscore.js +++ b/underscore.js @@ -174,7 +174,8 @@ }; // Determine if a given value is included in the array or object using `===`. - _.include = function(obj, target) { + // Aliased as `contains`. + _.include = _.contains = function(obj, target) { if (nativeIndexOf && obj.indexOf === nativeIndexOf) return obj.indexOf(target) != -1; var found = false; each(obj, function(value) { @@ -310,8 +311,8 @@ }; // Produce an array that contains every item shared between all the - // passed-in arrays. Aliased as `contains`. - _.intersect = _.contains = function(array) { + // passed-in arrays. + _.intersect = function(array) { var rest = slice.call(arguments, 1); return _.filter(_.uniq(array), function(item) { return _.every(rest, function(other) {