source: trip-planner-front/node_modules/arr-diff/index.js@ b738035

Last change on this file since b738035 was 6a3a178, checked in by Ema <ema_spirova@…>, 3 years ago

initial commit

  • Property mode set to 100644
File size: 805 bytes
Line 
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
8'use strict';
9
10module.exports = function diff(arr/*, arrays*/) {
11 var len = arguments.length;
12 var idx = 0;
13 while (++idx < len) {
14 arr = diffArray(arr, arguments[idx]);
15 }
16 return arr;
17};
18
19function diffArray(one, two) {
20 if (!Array.isArray(two)) {
21 return one.slice();
22 }
23
24 var tlen = two.length
25 var olen = one.length;
26 var idx = -1;
27 var arr = [];
28
29 while (++idx < olen) {
30 var ele = one[idx];
31
32 var hasEle = false;
33 for (var i = 0; i < tlen; i++) {
34 var val = two[i];
35
36 if (ele === val) {
37 hasEle = true;
38 break;
39 }
40 }
41
42 if (hasEle === false) {
43 arr.push(ele);
44 }
45 }
46 return arr;
47}
Note: See TracBrowser for help on using the repository browser.