aboutsummaryrefslogtreecommitdiff
path: root/node_modules/array-uniq
diff options
context:
space:
mode:
Diffstat (limited to 'node_modules/array-uniq')
-rw-r--r--node_modules/array-uniq/index.js62
-rw-r--r--node_modules/array-uniq/license21
-rw-r--r--node_modules/array-uniq/package.json73
-rw-r--r--node_modules/array-uniq/readme.md30
4 files changed, 186 insertions, 0 deletions
diff --git a/node_modules/array-uniq/index.js b/node_modules/array-uniq/index.js
new file mode 100644
index 0000000..edd09f8
--- /dev/null
+++ b/node_modules/array-uniq/index.js
@@ -0,0 +1,62 @@
+'use strict';
+
+// there's 3 implementations written in increasing order of efficiency
+
+// 1 - no Set type is defined
+function uniqNoSet(arr) {
+ var ret = [];
+
+ for (var i = 0; i < arr.length; i++) {
+ if (ret.indexOf(arr[i]) === -1) {
+ ret.push(arr[i]);
+ }
+ }
+
+ return ret;
+}
+
+// 2 - a simple Set type is defined
+function uniqSet(arr) {
+ var seen = new Set();
+ return arr.filter(function (el) {
+ if (!seen.has(el)) {
+ seen.add(el);
+ return true;
+ }
+
+ return false;
+ });
+}
+
+// 3 - a standard Set type is defined and it has a forEach method
+function uniqSetWithForEach(arr) {
+ var ret = [];
+
+ (new Set(arr)).forEach(function (el) {
+ ret.push(el);
+ });
+
+ return ret;
+}
+
+// V8 currently has a broken implementation
+// https://github.com/joyent/node/issues/8449
+function doesForEachActuallyWork() {
+ var ret = false;
+
+ (new Set([true])).forEach(function (el) {
+ ret = el;
+ });
+
+ return ret === true;
+}
+
+if ('Set' in global) {
+ if (typeof Set.prototype.forEach === 'function' && doesForEachActuallyWork()) {
+ module.exports = uniqSetWithForEach;
+ } else {
+ module.exports = uniqSet;
+ }
+} else {
+ module.exports = uniqNoSet;
+}
diff --git a/node_modules/array-uniq/license b/node_modules/array-uniq/license
new file mode 100644
index 0000000..654d0bf
--- /dev/null
+++ b/node_modules/array-uniq/license
@@ -0,0 +1,21 @@
+The MIT License (MIT)
+
+Copyright (c) Sindre Sorhus <sindresorhus@gmail.com> (sindresorhus.com)
+
+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/array-uniq/package.json b/node_modules/array-uniq/package.json
new file mode 100644
index 0000000..aab73f6
--- /dev/null
+++ b/node_modules/array-uniq/package.json
@@ -0,0 +1,73 @@
+{
+ "_args": [
+ [
+ "array-uniq@1.0.3",
+ "/home/dstaesse/git/website"
+ ]
+ ],
+ "_development": true,
+ "_from": "array-uniq@1.0.3",
+ "_id": "array-uniq@1.0.3",
+ "_inBundle": false,
+ "_integrity": "sha1-r2rId6Jcx/dOBYiUdThY39sk/bY=",
+ "_location": "/array-uniq",
+ "_phantomChildren": {},
+ "_requested": {
+ "type": "version",
+ "registry": true,
+ "raw": "array-uniq@1.0.3",
+ "name": "array-uniq",
+ "escapedName": "array-uniq",
+ "rawSpec": "1.0.3",
+ "saveSpec": null,
+ "fetchSpec": "1.0.3"
+ },
+ "_requiredBy": [
+ "/array-union"
+ ],
+ "_resolved": "https://registry.npmjs.org/array-uniq/-/array-uniq-1.0.3.tgz",
+ "_spec": "1.0.3",
+ "_where": "/home/dstaesse/git/website",
+ "author": {
+ "name": "Sindre Sorhus",
+ "email": "sindresorhus@gmail.com",
+ "url": "sindresorhus.com"
+ },
+ "bugs": {
+ "url": "https://github.com/sindresorhus/array-uniq/issues"
+ },
+ "description": "Create an array without duplicates",
+ "devDependencies": {
+ "ava": "*",
+ "es6-set": "^0.1.0",
+ "require-uncached": "^1.0.2",
+ "xo": "*"
+ },
+ "engines": {
+ "node": ">=0.10.0"
+ },
+ "files": [
+ "index.js"
+ ],
+ "homepage": "https://github.com/sindresorhus/array-uniq#readme",
+ "keywords": [
+ "array",
+ "arr",
+ "set",
+ "uniq",
+ "unique",
+ "es6",
+ "duplicate",
+ "remove"
+ ],
+ "license": "MIT",
+ "name": "array-uniq",
+ "repository": {
+ "type": "git",
+ "url": "git+https://github.com/sindresorhus/array-uniq.git"
+ },
+ "scripts": {
+ "test": "xo && ava"
+ },
+ "version": "1.0.3"
+}
diff --git a/node_modules/array-uniq/readme.md b/node_modules/array-uniq/readme.md
new file mode 100644
index 0000000..f0bd98c
--- /dev/null
+++ b/node_modules/array-uniq/readme.md
@@ -0,0 +1,30 @@
+# array-uniq [![Build Status](https://travis-ci.org/sindresorhus/array-uniq.svg?branch=master)](https://travis-ci.org/sindresorhus/array-uniq)
+
+> Create an array without duplicates
+
+It's already pretty fast, but will be much faster when [Set](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Set) becomes available in V8 (especially with large arrays).
+
+
+## Install
+
+```
+$ npm install --save array-uniq
+```
+
+
+## Usage
+
+```js
+const arrayUniq = require('array-uniq');
+
+arrayUniq([1, 1, 2, 3, 3]);
+//=> [1, 2, 3]
+
+arrayUniq(['foo', 'foo', 'bar', 'foo']);
+//=> ['foo', 'bar']
+```
+
+
+## License
+
+MIT © [Sindre Sorhus](https://sindresorhus.com)