meteor/meteor

Underscore 1.6.0 `_.intersection` bug (Meteor package)

alexdorsch opened this issue · 1 comments

Meteor 2.15 with Underscore 1.6.0

The Meteor version of of the _.intersection function in the underscore package returns unexpected results.

https://github.com/meteor/meteor/blob/master/packages/underscore/underscore.js#L528-L535

In the copy of the function below, _.contains returns boolean, so the >= 0 comparison should be removed:

_.intersection = function(array) {
  var rest = slice.call(arguments, 1);
  return _.filter(_.uniq(array), function(item) {
    return _.every(rest, function(other) {
      return _.contains(other, item) >= 0;
    });
  });
};

Interestingly the v1.6.0 commit in the underscore repo doesn't have this problem:

https://github.com/jashkenas/underscore/blob/1f4bf626f23a99f7a676f5076dc1b1475554c8f7/underscore.js#L506

I must have missed something in my upgrade then.
I'm working on updating to the next version here: #12994