source: trip-planner-front/node_modules/uniq/README.md@ 8d391a1

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

initial commit

  • Property mode set to 100644
File size: 1.2 KB
Line 
1uniq
2====
3Removes all duplicates from an array in place.
4
5Usage
6=====
7First install using npm:
8
9 npm install uniq
10
11Then use it as follows:
12
13```javascript
14
15var arr = [1, 1, 2, 2, 3, 5]
16
17require("uniq")(arr)
18console.log(arr)
19
20//Prints:
21//
22// 1,2,3,5
23//
24```
25
26## `require("uniq")(array[, compare, sorted])`
27Removes all duplicates from a sorted array in place.
28
29* `array` is the array to remove items from
30* `compare` is an optional comparison function that returns 0 when two items are equal, and something non-zero when they are different. If unspecified, then the default equals will be used.
31* `sorted` if true, then assume array is already sorted
32
33**Returns:** A reference to `array`
34
35**Time Complexity:** `O(array.length * log(arra.length))` or `O(array.length)` if `sorted`
36
37
38## Why use this instead of underscore.uniq[ue]?
39A few reasons:
40
41* This library updates the array in place without making an extra copy (and so it is faster for large arrays)
42* It also accepts a custom comparison function so you can remove duplicates from arrays containing object
43* It is more modular in the sense that it doesn't come with a bazillion other utility grab bag functions.
44
45# Credits
46(c) 2013 Mikola Lysenko. MIT License
Note: See TracBrowser for help on using the repository browser.