Açıklama Yok

index.js 805B

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647
  1. /*!
  2. * arr-diff <https://github.com/jonschlinkert/arr-diff>
  3. *
  4. * Copyright (c) 2014-2017, Jon Schlinkert.
  5. * Released under the MIT License.
  6. */
  7. 'use strict';
  8. module.exports = function diff(arr/*, arrays*/) {
  9. var len = arguments.length;
  10. var idx = 0;
  11. while (++idx < len) {
  12. arr = diffArray(arr, arguments[idx]);
  13. }
  14. return arr;
  15. };
  16. function diffArray(one, two) {
  17. if (!Array.isArray(two)) {
  18. return one.slice();
  19. }
  20. var tlen = two.length
  21. var olen = one.length;
  22. var idx = -1;
  23. var arr = [];
  24. while (++idx < olen) {
  25. var ele = one[idx];
  26. var hasEle = false;
  27. for (var i = 0; i < tlen; i++) {
  28. var val = two[i];
  29. if (ele === val) {
  30. hasEle = true;
  31. break;
  32. }
  33. }
  34. if (hasEle === false) {
  35. arr.push(ele);
  36. }
  37. }
  38. return arr;
  39. }