aboutsummaryrefslogtreecommitdiff
path: root/node_modules/uniq
diff options
context:
space:
mode:
Diffstat (limited to 'node_modules/uniq')
-rw-r--r--node_modules/uniq/.npmignore15
-rw-r--r--node_modules/uniq/LICENSE22
-rw-r--r--node_modules/uniq/README.md46
-rw-r--r--node_modules/uniq/package.json36
-rw-r--r--node_modules/uniq/test/test.js11
-rw-r--r--node_modules/uniq/uniq.js57
6 files changed, 187 insertions, 0 deletions
diff --git a/node_modules/uniq/.npmignore b/node_modules/uniq/.npmignore
new file mode 100644
index 00000000..0d1b0b09
--- /dev/null
+++ b/node_modules/uniq/.npmignore
@@ -0,0 +1,15 @@
+lib-cov
+*.seed
+*.log
+*.csv
+*.dat
+*.out
+*.pid
+*.gz
+
+pids
+logs
+results
+
+npm-debug.log
+node_modules/* \ No newline at end of file
diff --git a/node_modules/uniq/LICENSE b/node_modules/uniq/LICENSE
new file mode 100644
index 00000000..8ce206a8
--- /dev/null
+++ b/node_modules/uniq/LICENSE
@@ -0,0 +1,22 @@
+
+The MIT License (MIT)
+
+Copyright (c) 2013 Mikola Lysenko
+
+Permission is hereby granted, free of charge, to any person obtaining a copy
+of this software and associated documentation files (the "Software"), to deal
+in the Software without restriction, including without limitation the rights
+to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+copies of the Software, and to permit persons to whom the Software is
+furnished to do so, subject to the following conditions:
+
+The above copyright notice and this permission notice shall be included in
+all copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
+THE SOFTWARE.
diff --git a/node_modules/uniq/README.md b/node_modules/uniq/README.md
new file mode 100644
index 00000000..9e0abafe
--- /dev/null
+++ b/node_modules/uniq/README.md
@@ -0,0 +1,46 @@
+uniq
+====
+Removes all duplicates from an array in place.
+
+Usage
+=====
+First install using npm:
+
+ npm install uniq
+
+Then use it as follows:
+
+```javascript
+
+var arr = [1, 1, 2, 2, 3, 5]
+
+require("uniq")(arr)
+console.log(arr)
+
+//Prints:
+//
+// 1,2,3,5
+//
+```
+
+## `require("uniq")(array[, compare, sorted])`
+Removes all duplicates from a sorted array in place.
+
+* `array` is the array to remove items from
+* `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.
+* `sorted` if true, then assume array is already sorted
+
+**Returns:** A reference to `array`
+
+**Time Complexity:** `O(array.length * log(arra.length))` or `O(array.length)` if `sorted`
+
+
+## Why use this instead of underscore.uniq[ue]?
+A few reasons:
+
+* This library updates the array in place without making an extra copy (and so it is faster for large arrays)
+* It also accepts a custom comparison function so you can remove duplicates from arrays containing object
+* It is more modular in the sense that it doesn't come with a bazillion other utility grab bag functions.
+
+# Credits
+(c) 2013 Mikola Lysenko. MIT License
diff --git a/node_modules/uniq/package.json b/node_modules/uniq/package.json
new file mode 100644
index 00000000..9c91dda0
--- /dev/null
+++ b/node_modules/uniq/package.json
@@ -0,0 +1,36 @@
+{
+ "name": "uniq",
+ "version": "1.0.1",
+ "description": "Removes duplicates from a sorted array in place",
+ "main": "uniq.js",
+ "directories": {
+ "test": "test"
+ },
+ "dependencies": {},
+ "devDependencies": {
+ "tape": "^2.12.3"
+ },
+ "scripts": {
+ "test": "tape test/*.js"
+ },
+ "repository": {
+ "type": "git",
+ "url": "git://github.com/mikolalysenko/uniq.git"
+ },
+ "keywords": [
+ "array",
+ "duplicate",
+ "unique",
+ "uniq",
+ "remove",
+ "sort",
+ "in",
+ "place",
+ "no",
+ "copy"
+ ],
+ "author": "Mikola Lysenko",
+ "license": "MIT",
+ "readmeFilename": "README.md",
+ "gitHead": "e9828cfcb97e25a351f95b39fdf3c31876ff3985"
+}
diff --git a/node_modules/uniq/test/test.js b/node_modules/uniq/test/test.js
new file mode 100644
index 00000000..efc4fc8b
--- /dev/null
+++ b/node_modules/uniq/test/test.js
@@ -0,0 +1,11 @@
+var unique = require("../uniq.js")
+
+require("tape")("unique", function(t) {
+
+ t.equals(unique([1,1,2,3,5,5,7]).join(), [1,2,3,5,7].join())
+ t.equals(unique([]).join(), [].join())
+ t.equals(unique([1,1,1]).join(), [1].join())
+ t.equals(unique([1,1,1,2,2,2], function(a,b) { return (a^b)&1 }).join(), [2,1].join())
+
+ t.end()
+}) \ No newline at end of file
diff --git a/node_modules/uniq/uniq.js b/node_modules/uniq/uniq.js
new file mode 100644
index 00000000..e86c44b5
--- /dev/null
+++ b/node_modules/uniq/uniq.js
@@ -0,0 +1,57 @@
+"use strict"
+
+function unique_pred(list, compare) {
+ var ptr = 1
+ , len = list.length
+ , a=list[0], b=list[0]
+ for(var i=1; i<len; ++i) {
+ b = a
+ a = list[i]
+ if(compare(a, b)) {
+ if(i === ptr) {
+ ptr++
+ continue
+ }
+ list[ptr++] = a
+ }
+ }
+ list.length = ptr
+ return list
+}
+
+function unique_eq(list) {
+ var ptr = 1
+ , len = list.length
+ , a=list[0], b = list[0]
+ for(var i=1; i<len; ++i, b=a) {
+ b = a
+ a = list[i]
+ if(a !== b) {
+ if(i === ptr) {
+ ptr++
+ continue
+ }
+ list[ptr++] = a
+ }
+ }
+ list.length = ptr
+ return list
+}
+
+function unique(list, compare, sorted) {
+ if(list.length === 0) {
+ return list
+ }
+ if(compare) {
+ if(!sorted) {
+ list.sort(compare)
+ }
+ return unique_pred(list, compare)
+ }
+ if(!sorted) {
+ list.sort()
+ }
+ return unique_eq(list)
+}
+
+module.exports = unique