1
0

exclusion.js 767 B

123456789101112131415161718192021222324252627
  1. 'use strict';
  2. var value = require('../../object/valid-value')
  3. , aFrom = require('../from')
  4. , toArray = require('../to-array')
  5. , contains = require('./contains')
  6. , byLength = require('./_compare-by-length')
  7. , filter = Array.prototype.filter, push = Array.prototype.push;
  8. module.exports = function (/*…lists*/) {
  9. var lists, seen, result;
  10. if (!arguments.length) return aFrom(this);
  11. push.apply(lists = [this], arguments);
  12. lists.forEach(value);
  13. seen = [];
  14. result = [];
  15. lists.sort(byLength).forEach(function (list) {
  16. result = result.filter(function (item) {
  17. return !contains.call(list, item);
  18. }).concat(filter.call(list, function (x) {
  19. return !contains.call(seen, x);
  20. }));
  21. push.apply(seen, toArray(list));
  22. });
  23. return result;
  24. };