exclusion.js 782 B

12345678910111213141516171819202122232425
  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
  8. , push = Array.prototype.push;
  9. module.exports = function (/* …lists*/) {
  10. var lists, seen, result;
  11. if (!arguments.length) return aFrom(this);
  12. push.apply((lists = [this]), arguments);
  13. lists.forEach(value);
  14. seen = [];
  15. result = [];
  16. lists.sort(byLength).forEach(function (list) {
  17. result = result
  18. .filter(function (item) { return !contains.call(list, item); })
  19. .concat(filter.call(list, function (item) { return !contains.call(seen, item); }));
  20. push.apply(seen, toArray(list));
  21. });
  22. return result;
  23. };