mirror of
https://github.com/whoisclebs/lodash.git
synced 2026-02-07 10:07:48 +00:00
fixing mistakenly-aliased contains ... should refer to include.
This commit is contained in:
@@ -111,7 +111,7 @@ $(document).ready(function() {
|
|||||||
test('collections: include', function() {
|
test('collections: include', function() {
|
||||||
ok(_.include([1,2,3], 2), 'two is in the array');
|
ok(_.include([1,2,3], 2), 'two is in the array');
|
||||||
ok(!_.include([1,3,9], 2), 'two is not 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');
|
ok(_([1,2,3]).include(2), 'OO-style include');
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|||||||
@@ -174,7 +174,8 @@
|
|||||||
};
|
};
|
||||||
|
|
||||||
// Determine if a given value is included in the array or object using `===`.
|
// 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;
|
if (nativeIndexOf && obj.indexOf === nativeIndexOf) return obj.indexOf(target) != -1;
|
||||||
var found = false;
|
var found = false;
|
||||||
each(obj, function(value) {
|
each(obj, function(value) {
|
||||||
@@ -310,8 +311,8 @@
|
|||||||
};
|
};
|
||||||
|
|
||||||
// Produce an array that contains every item shared between all the
|
// Produce an array that contains every item shared between all the
|
||||||
// passed-in arrays. Aliased as `contains`.
|
// passed-in arrays.
|
||||||
_.intersect = _.contains = function(array) {
|
_.intersect = function(array) {
|
||||||
var rest = slice.call(arguments, 1);
|
var rest = slice.call(arguments, 1);
|
||||||
return _.filter(_.uniq(array), function(item) {
|
return _.filter(_.uniq(array), function(item) {
|
||||||
return _.every(rest, function(other) {
|
return _.every(rest, function(other) {
|
||||||
|
|||||||
Reference in New Issue
Block a user