diff.js 349 B

12345678910111213141516
  1. 'use strict';
  2. module.exports = function diff(values) {
  3. var valuesToDiff;
  4. if (values instanceof this.constructor) {
  5. valuesToDiff = values.all();
  6. } else {
  7. valuesToDiff = values;
  8. }
  9. var collection = this.items.filter(function (item) {
  10. return valuesToDiff.indexOf(item) === -1;
  11. });
  12. return new this.constructor(collection);
  13. };