source: trip-planner-front/node_modules/array-unique/index.js@ 1ad8e64

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

initial commit

  • Property mode set to 100644
File size: 829 bytes
Line 
1/*!
2 * array-unique <https://github.com/jonschlinkert/array-unique>
3 *
4 * Copyright (c) 2014-2015, Jon Schlinkert.
5 * Licensed under the MIT License.
6 */
7
8'use strict';
9
10module.exports = function unique(arr) {
11 if (!Array.isArray(arr)) {
12 throw new TypeError('array-unique expects an array.');
13 }
14
15 var len = arr.length;
16 var i = -1;
17
18 while (i++ < len) {
19 var j = i + 1;
20
21 for (; j < arr.length; ++j) {
22 if (arr[i] === arr[j]) {
23 arr.splice(j--, 1);
24 }
25 }
26 }
27 return arr;
28};
29
30module.exports.immutable = function uniqueImmutable(arr) {
31 if (!Array.isArray(arr)) {
32 throw new TypeError('array-unique expects an array.');
33 }
34
35 var arrLen = arr.length;
36 var newArr = new Array(arrLen);
37
38 for (var i = 0; i < arrLen; i++) {
39 newArr[i] = arr[i];
40 }
41
42 return module.exports(newArr);
43};
Note: See TracBrowser for help on using the repository browser.