pax_global_header00006660000000000000000000000064127305147430014520gustar00rootroot0000000000000052 comment=3b5bf5a90a585b3950284d575f33d09663f6083a array-uniq-1.0.3/000077500000000000000000000000001273051474300136115ustar00rootroot00000000000000array-uniq-1.0.3/.editorconfig000066400000000000000000000002761273051474300162730ustar00rootroot00000000000000root = true [*] indent_style = tab end_of_line = lf charset = utf-8 trim_trailing_whitespace = true insert_final_newline = true [{package.json,*.yml}] indent_style = space indent_size = 2 array-uniq-1.0.3/.gitattributes000066400000000000000000000000141273051474300164770ustar00rootroot00000000000000* text=auto array-uniq-1.0.3/.gitignore000066400000000000000000000000151273051474300155750ustar00rootroot00000000000000node_modules array-uniq-1.0.3/.travis.yml000066400000000000000000000001151273051474300157170ustar00rootroot00000000000000sudo: false language: node_js node_js: - '6' - '4' - '0.12' - '0.10' array-uniq-1.0.3/index.js000066400000000000000000000021561273051474300152620ustar00rootroot00000000000000'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; } array-uniq-1.0.3/license000066400000000000000000000021371273051474300151610ustar00rootroot00000000000000The MIT License (MIT) Copyright (c) Sindre Sorhus (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. array-uniq-1.0.3/package.json000066400000000000000000000012041273051474300160740ustar00rootroot00000000000000{ "name": "array-uniq", "version": "1.0.3", "description": "Create an array without duplicates", "license": "MIT", "repository": "sindresorhus/array-uniq", "author": { "name": "Sindre Sorhus", "email": "sindresorhus@gmail.com", "url": "sindresorhus.com" }, "engines": { "node": ">=0.10.0" }, "scripts": { "test": "xo && ava" }, "files": [ "index.js" ], "keywords": [ "array", "arr", "set", "uniq", "unique", "es6", "duplicate", "remove" ], "devDependencies": { "ava": "*", "es6-set": "^0.1.0", "require-uncached": "^1.0.2", "xo": "*" } } array-uniq-1.0.3/readme.md000066400000000000000000000012371273051474300153730ustar00rootroot00000000000000# 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) array-uniq-1.0.3/test.js000066400000000000000000000010731273051474300151270ustar00rootroot00000000000000require('es6-set/implement'); const test = require('ava'); const requireUncached = require('require-uncached'); test('removes duplicates from an array', t => { const m = require('./'); t.deepEqual(m([1, 2, 2, 3, 1, 2, 4]), [1, 2, 3, 4]); t.deepEqual(m(['a', 'a', 'b', 'a', 'c', 'a', 'd']), ['a', 'b', 'c', 'd']); }); test('removes duplicates from an array using Set', t => { delete global.Set; const m = requireUncached('./'); t.deepEqual(m([1, 2, 2, 3, 1, 2, 4]), [1, 2, 3, 4]); t.deepEqual(m(['a', 'a', 'b', 'a', 'c', 'a', 'd']), ['a', 'b', 'c', 'd']); });