pax_global_header00006660000000000000000000000064126630532040014513gustar00rootroot0000000000000052 comment=ede857f5d5082467534e372fd3da45ce5e782e93 arr-union-3.1.0/000077500000000000000000000000001266305320400134265ustar00rootroot00000000000000arr-union-3.1.0/.editorconfig000066400000000000000000000006121266305320400161020ustar00rootroot00000000000000# http://editorconfig.org root = true [*] indent_style = space end_of_line = lf charset = utf-8 indent_size = 2 trim_trailing_whitespace = true insert_final_newline = true [*.md] trim_trailing_whitespace = false insert_final_newline = false [test/**] trim_trailing_whitespace = false insert_final_newline = false [templates/**] trim_trailing_whitespace = false insert_final_newline = false arr-union-3.1.0/.eslintrc.json000066400000000000000000000071251266305320400162270ustar00rootroot00000000000000{ "ecmaFeatures": { "modules": true, "experimentalObjectRestSpread": true }, "env": { "browser": false, "es6": true, "node": true, "mocha": true }, "globals": { "document": false, "navigator": false, "window": false }, "rules": { "accessor-pairs": 2, "arrow-spacing": [2, { "before": true, "after": true }], "block-spacing": [2, "always"], "brace-style": [2, "1tbs", { "allowSingleLine": true }], "comma-dangle": [2, "never"], "comma-spacing": [2, { "before": false, "after": true }], "comma-style": [2, "last"], "constructor-super": 2, "curly": [2, "multi-line"], "dot-location": [2, "property"], "eol-last": 2, "eqeqeq": [2, "allow-null"], "generator-star-spacing": [2, { "before": true, "after": true }], "handle-callback-err": [2, "^(err|error)$" ], "indent": [2, 2, { "SwitchCase": 1 }], "key-spacing": [2, { "beforeColon": false, "afterColon": true }], "keyword-spacing": [2, { "before": true, "after": true }], "new-cap": [2, { "newIsCap": true, "capIsNew": false }], "new-parens": 2, "no-array-constructor": 2, "no-caller": 2, "no-class-assign": 2, "no-cond-assign": 2, "no-const-assign": 2, "no-control-regex": 2, "no-debugger": 2, "no-delete-var": 2, "no-dupe-args": 2, "no-dupe-class-members": 2, "no-dupe-keys": 2, "no-duplicate-case": 2, "no-empty-character-class": 2, "no-eval": 2, "no-ex-assign": 2, "no-extend-native": 2, "no-extra-bind": 2, "no-extra-boolean-cast": 2, "no-extra-parens": [2, "functions"], "no-fallthrough": 2, "no-floating-decimal": 2, "no-func-assign": 2, "no-implied-eval": 2, "no-inner-declarations": [2, "functions"], "no-invalid-regexp": 2, "no-irregular-whitespace": 2, "no-iterator": 2, "no-label-var": 2, "no-labels": 2, "no-lone-blocks": 2, "no-mixed-spaces-and-tabs": 2, "no-multi-spaces": 2, "no-multi-str": 2, "no-multiple-empty-lines": [2, { "max": 1 }], "no-native-reassign": 0, "no-negated-in-lhs": 2, "no-new": 2, "no-new-func": 2, "no-new-object": 2, "no-new-require": 2, "no-new-wrappers": 2, "no-obj-calls": 2, "no-octal": 2, "no-octal-escape": 2, "no-proto": 0, "no-redeclare": 2, "no-regex-spaces": 2, "no-return-assign": 2, "no-self-compare": 2, "no-sequences": 2, "no-shadow-restricted-names": 2, "no-spaced-func": 2, "no-sparse-arrays": 2, "no-this-before-super": 2, "no-throw-literal": 2, "no-trailing-spaces": 0, "no-undef": 2, "no-undef-init": 2, "no-unexpected-multiline": 2, "no-unneeded-ternary": [2, { "defaultAssignment": false }], "no-unreachable": 2, "no-unused-vars": [2, { "vars": "all", "args": "none" }], "no-useless-call": 0, "no-with": 2, "one-var": [0, { "initialized": "never" }], "operator-linebreak": [0, "after", { "overrides": { "?": "before", ":": "before" } }], "padded-blocks": [0, "never"], "quotes": [2, "single", "avoid-escape"], "radix": 2, "semi": [2, "always"], "semi-spacing": [2, { "before": false, "after": true }], "space-before-blocks": [2, "always"], "space-before-function-paren": [2, "never"], "space-in-parens": [2, "never"], "space-infix-ops": 2, "space-unary-ops": [2, { "words": true, "nonwords": false }], "spaced-comment": [0, "always", { "markers": ["global", "globals", "eslint", "eslint-disable", "*package", "!", ","] }], "use-isnan": 2, "valid-typeof": 2, "wrap-iife": [2, "any"], "yoda": [2, "never"] } } arr-union-3.1.0/.gitattributes000066400000000000000000000001771266305320400163260ustar00rootroot00000000000000# Enforce Unix newlines * text eol=lf # binaries *.ai binary *.psd binary *.jpg binary *.gif binary *.png binary *.jpeg binaryarr-union-3.1.0/.gitignore000066400000000000000000000010061266305320400154130ustar00rootroot00000000000000# Numerous always-ignore extensions *.DS_Store *.csv *.dat *.diff *.err *.gz *.log *.orig *.out *.pid *.rar *.rej *.seed *.swo *.swp *.vi *.yo-rc.json *.zip *~ .ruby-version lib-cov npm-debug.log # Always-ignore dirs /bower_components/ /node_modules/ /temp/ /tmp/ /vendor/ _gh_pages # OS or Editor folders *.esproj *.komodoproject .komodotools *.sublime-* ._* .cache .DS_Store .idea .project .settings .tmproj nbproject Thumbs.db # grunt-html-validation validation-status.json validation-report.json # misc TODO.mdarr-union-3.1.0/.travis.yml000066400000000000000000000002361266305320400155400ustar00rootroot00000000000000sudo: false language: node_js node_js: - "stable" - "5" - "4" - "0.12" - "0.10" matrix: fast_finish: true allow_failures: - node_js: "0.10" arr-union-3.1.0/.verb.md000066400000000000000000000007221266305320400147650ustar00rootroot00000000000000## Benchmarks This library is **10-20 times faster** and more performant than [array-union][]. See the [benchmarks](./benchmark). ```sh {%= doc('benchmark/last.md') %} ``` ## Usage ```js var union = require('{%= name %}'); union(['a'], ['b', 'c'], ['d', 'e', 'f']); //=> ['a', 'b', 'c', 'd', 'e', 'f'] ``` Returns only unique elements: ```js union(['a', 'a'], ['b', 'c']); //=> ['a', 'b', 'c'] ``` [array-union]: https://github.com/sindresorhus/array-union arr-union-3.1.0/LICENSE000066400000000000000000000021001266305320400144240ustar00rootroot00000000000000The MIT License (MIT) Copyright (c) 2014-2016, Jon Schlinkert. 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. arr-union-3.1.0/README.md000066400000000000000000000067541266305320400147210ustar00rootroot00000000000000# arr-union [![NPM version](https://img.shields.io/npm/v/arr-union.svg)](https://www.npmjs.com/package/arr-union) [![Build Status](https://img.shields.io/travis/jonschlinkert/arr-union.svg)](https://travis-ci.org/jonschlinkert/arr-union) > Combines a list of arrays, returning a single array with unique values, using strict equality for comparisons. ## Install Install with [npm](https://www.npmjs.com/): ```sh $ npm i arr-union --save ``` ## Benchmarks This library is **10-20 times faster** and more performant than [array-union](https://github.com/sindresorhus/array-union). See the [benchmarks](./benchmark). ```sh #1: five-arrays array-union x 511,121 ops/sec ±0.80% (96 runs sampled) arr-union x 5,716,039 ops/sec ±0.86% (93 runs sampled) #2: ten-arrays array-union x 245,196 ops/sec ±0.69% (94 runs sampled) arr-union x 1,850,786 ops/sec ±0.84% (97 runs sampled) #3: two-arrays array-union x 563,869 ops/sec ±0.97% (94 runs sampled) arr-union x 9,602,852 ops/sec ±0.87% (92 runs sampled) ``` ## Usage ```js var union = require('arr-union'); union(['a'], ['b', 'c'], ['d', 'e', 'f']); //=> ['a', 'b', 'c', 'd', 'e', 'f'] ``` Returns only unique elements: ```js union(['a', 'a'], ['b', 'c']); //=> ['a', 'b', 'c'] ``` ## Related projects * [arr-diff](https://www.npmjs.com/package/arr-diff): Returns an array with only the unique values from the first array, by excluding all… [more](https://www.npmjs.com/package/arr-diff) | [homepage](https://github.com/jonschlinkert/arr-diff) * [arr-filter](https://www.npmjs.com/package/arr-filter): Faster alternative to javascript's native filter method. | [homepage](https://github.com/jonschlinkert/arr-filter) * [arr-flatten](https://www.npmjs.com/package/arr-flatten): Recursively flatten an array or arrays. This is the fastest implementation of array flatten. | [homepage](https://github.com/jonschlinkert/arr-flatten) * [arr-map](https://www.npmjs.com/package/arr-map): Faster, node.js focused alternative to JavaScript's native array map. | [homepage](https://github.com/jonschlinkert/arr-map) * [arr-pluck](https://www.npmjs.com/package/arr-pluck): Retrieves the value of a specified property from all elements in the collection. | [homepage](https://github.com/jonschlinkert/arr-pluck) * [arr-reduce](https://www.npmjs.com/package/arr-reduce): Fast array reduce that also loops over sparse elements. | [homepage](https://github.com/jonschlinkert/arr-reduce) * [array-unique](https://www.npmjs.com/package/array-unique): Return an array free of duplicate values. Fastest ES5 implementation. | [homepage](https://github.com/jonschlinkert/array-unique) ## Contributing Pull requests and stars are always welcome. For bugs and feature requests, [please create an issue](https://github.com/jonschlinkert/arr-union/issues/new). ## Building docs Generate readme and API documentation with [verb](https://github.com/verbose/verb): ```sh $ npm i verb && npm run docs ``` Or, if [verb](https://github.com/verbose/verb) is installed globally: ```sh $ verb ``` ## Running tests Install dev dependencies: ```sh $ npm i -d && npm test ``` ## Author **Jon Schlinkert** * [github/jonschlinkert](https://github.com/jonschlinkert) * [twitter/jonschlinkert](http://twitter.com/jonschlinkert) ## License Copyright © 2016 [Jon Schlinkert](https://github.com/jonschlinkert) Released under the [MIT license](https://github.com/jonschlinkert/arr-union/blob/master/LICENSE). *** _This file was generated by [verb](https://github.com/verbose/verb), v0.9.0, on February 23, 2016._arr-union-3.1.0/benchmark/000077500000000000000000000000001266305320400153605ustar00rootroot00000000000000arr-union-3.1.0/benchmark/check.js000066400000000000000000000012011266305320400167650ustar00rootroot00000000000000'use strict'; var fs = require('fs'); var path = require('path'); var bold = require('ansi-bold'); /** * Sanity check. run to ensure that all fns return a correct * result. */ fs.readdirSync(__dirname + '/code').forEach(function (fp) { var fn = require(path.resolve(__dirname, 'code', fp)); var name = path.basename(fp, path.extname(fp)); if (/./.test(name)) { fs.readdirSync(__dirname + '/fixtures').forEach(function (fixture) { fixture = path.resolve(__dirname, 'fixtures', fixture); if (/\.js$/.test(fixture)) { console.log(bold(name) + ':', fn.apply(null, require(fixture))); } }); } }); arr-union-3.1.0/benchmark/code/000077500000000000000000000000001266305320400162725ustar00rootroot00000000000000arr-union-3.1.0/benchmark/code/2-1-0.js000066400000000000000000000006021266305320400172620ustar00rootroot00000000000000module.exports = function union(arr) { var len = arguments.length; var res = [], i = 0; while (len--) { var arg = arrayify(arguments[i++]); for (var j = 0; j < arg.length; j++) { var ele = arg[j]; if (res.indexOf(ele) === -1) { res.push(ele); } } } return res; }; function arrayify(val) { return Array.isArray(val) ? val : [val]; } arr-union-3.1.0/benchmark/code/array-union.js000066400000000000000000000000511266305320400210700ustar00rootroot00000000000000module.exports = require('array-union'); arr-union-3.1.0/benchmark/code/concat-apply.js000066400000000000000000000002211266305320400212150ustar00rootroot00000000000000'use strict'; var unique = require('array-unique'); module.exports = function union(arr) { return unique([].concat.apply([], arguments)); }; arr-union-3.1.0/benchmark/code/current.js000066400000000000000000000001251266305320400203100ustar00rootroot00000000000000'use strict'; /** * Current implementation */ module.exports = require('../..'); arr-union-3.1.0/benchmark/code/for-concat.js000066400000000000000000000003441266305320400206640ustar00rootroot00000000000000'use strict'; var unique = require('array-unique'); module.exports = function union(init) { var len = arguments.length; for (var i = 1; i < len; i++) { init = init.concat(arguments[i]); } return unique(init); }; arr-union-3.1.0/benchmark/code/for-each.js000066400000000000000000000004071266305320400203150ustar00rootroot00000000000000'use strict'; var unique = require('array-unique'); module.exports = function diff(init) { var args = [].slice.call(arguments, 1); args.forEach(function (arr) { arr.forEach(function(ele) { init.push(ele); }); }); return unique(init); }; arr-union-3.1.0/benchmark/code/for-in.js000066400000000000000000000005411266305320400200220ustar00rootroot00000000000000'use strict'; module.exports = function unique(init) { var args = [].slice.call(arguments); var len = args.length; for (var i = 1; i < len; i++) { var arr = args[i]; var alen = arr.length; while (alen--) { var ele = arr[alen]; if (init.indexOf(ele) === -1) { init.push(ele); } } } return init; }; arr-union-3.1.0/benchmark/code/for.js000066400000000000000000000004201266305320400174120ustar00rootroot00000000000000'use strict'; var unique = require('array-unique'); module.exports = function union(init) { var arr = [].slice.call(arguments, 1); var len = arr.length; for (var i = 0; i < len; i++) { init = init.concat(arr[i]); } init = unique(init); return init; }; arr-union-3.1.0/benchmark/code/reduce.js000066400000000000000000000003671266305320400201050ustar00rootroot00000000000000'use strict'; var unique = require('array-unique'); module.exports = function union(init/*, arrays*/) { var arrays = [].slice.call(arguments, 1); return unique(arrays.reduce(function (acc, arr) { return acc.concat(arr); }, init)); }; arr-union-3.1.0/benchmark/code/while-concat-push.js000066400000000000000000000004051266305320400221610ustar00rootroot00000000000000'use strict'; module.exports = function union() { var arr = [].concat.apply([], arguments); var len = arr.length; var res = []; while (len--) { var ele = arr[len]; if (res.indexOf(ele) === -1) { res.push(ele); } } return res; }; arr-union-3.1.0/benchmark/code/while-concat.js000066400000000000000000000003361266305320400212070ustar00rootroot00000000000000'use strict'; var unique = require('array-unique'); module.exports = function union() { var len = arguments.length; var res = []; while (len--) { res = res.concat(arguments[len]); } return unique(res); }; arr-union-3.1.0/benchmark/code/while-continue-for.js000066400000000000000000000005041266305320400223450ustar00rootroot00000000000000'use strict'; module.exports = function union(init) { var len = arguments.length, i = 0; while (++i < len) { var arg = arguments[i]; for (var j = 0; j < arg.length; j++) { var ele = arg[j]; if (init.indexOf(ele) >= 0) { continue; } init.push(ele); } } return init; }; arr-union-3.1.0/benchmark/code/while-for-unique.js000066400000000000000000000004371266305320400220340ustar00rootroot00000000000000'use strict'; var unique = require('array-unique'); module.exports = function union(init) { var len = arguments.length, i = 0; while (++i < len) { var arg = arguments[i]; for (var j = 0; j < arg.length; j++) { init.push(arg[j]); } } return unique(init); }; arr-union-3.1.0/benchmark/code/while-for.js000066400000000000000000000004661266305320400205320ustar00rootroot00000000000000'use strict'; module.exports = function union(init) { var len = arguments.length, i = 0; while (++i < len) { var arg = arguments[i]; for (var j = 0; j < arg.length; j++) { var ele = arg[j]; if (init.indexOf(ele) === -1) { init.push(ele); } } } return init; }; arr-union-3.1.0/benchmark/code/while-push-apply.js000066400000000000000000000003411266305320400220360ustar00rootroot00000000000000'use strict'; var unique = require('array-unique'); module.exports = function union(init) { var len = arguments.length, i = 0; while (++i < len) { init.push.apply(init, arguments[i]); } return unique(init); }; arr-union-3.1.0/benchmark/code/while-seen.js000066400000000000000000000004501266305320400206670ustar00rootroot00000000000000'use strict'; module.exports = function union() { var args = [].concat.apply([], arguments); var len = args.length; var seen = {}; var res = []; while (len--) { var ele = args[len]; if (!!seen[ele]) { continue; } res.push(seen[ele] = ele); } return res; }; arr-union-3.1.0/benchmark/code/while-while-unique.js000066400000000000000000000004471266305320400223570ustar00rootroot00000000000000'use strict'; var unique = require('array-unique'); module.exports = function union(init) { var len = arguments.length, i = 0; while (++i < len) { var arg = arguments[i]; var alen = arg.length; while (alen--) { init.push(arg[alen]); } } return unique(init); }; arr-union-3.1.0/benchmark/code/while-while.js000066400000000000000000000006251266305320400210510ustar00rootroot00000000000000'use strict'; module.exports = function union(init) { var len = arguments.length, i = 0; while (++i < len) { var arg = arrayify(arguments[i]); var alen = arg.length, j = 0; while (alen--) { var ele = arg[j++]; if (init.indexOf(ele) === -1) { init.push(ele); } } } return init; }; function arrayify(val) { return Array.isArray(val) ? val : [val]; } arr-union-3.1.0/benchmark/fixtures/000077500000000000000000000000001266305320400172315ustar00rootroot00000000000000arr-union-3.1.0/benchmark/fixtures/five-arrays.js000066400000000000000000000001241266305320400220140ustar00rootroot00000000000000module.exports = [['a', 'b', 'c'], ['a', 'b'], ['a', 'b'], ['b', 'f'], ['a', 'b']]; arr-union-3.1.0/benchmark/fixtures/ten-arrays.js000066400000000000000000000002341266305320400216530ustar00rootroot00000000000000module.exports = [['a', 'b', 'c'], ['a', 'b'], ['a', 'b'], ['b', 'f'], ['a', 'b'], ['z', 'x', 'y'], ['y', 'k'], ['u', 'i', 'i'], [456, 'ten'], ['a', 'z']]; arr-union-3.1.0/benchmark/fixtures/two-arrays.js000066400000000000000000000000651266305320400217000ustar00rootroot00000000000000module.exports = [['a', 'b', 'c'], ['b', 'f', 'g']]; arr-union-3.1.0/benchmark/index.js000066400000000000000000000003121266305320400170210ustar00rootroot00000000000000'use strict'; var Suite = require('benchmarked'); var suite = new Suite({ result: false, fixtures: 'fixtures/*.js', add: 'code/{2-1-0,current,array-union}.js', cwd: __dirname }); suite.run(); arr-union-3.1.0/benchmark/last.md000066400000000000000000000006131266305320400166450ustar00rootroot00000000000000#1: five-arrays array-union x 511,121 ops/sec ±0.80% (96 runs sampled) arr-union x 5,716,039 ops/sec ±0.86% (93 runs sampled) #2: ten-arrays array-union x 245,196 ops/sec ±0.69% (94 runs sampled) arr-union x 1,850,786 ops/sec ±0.84% (97 runs sampled) #3: two-arrays array-union x 563,869 ops/sec ±0.97% (94 runs sampled) arr-union x 9,602,852 ops/sec ±0.87% (92 runs sampled)arr-union-3.1.0/index.js000066400000000000000000000010171266305320400150720ustar00rootroot00000000000000'use strict'; module.exports = function union(init) { if (!Array.isArray(init)) { throw new TypeError('arr-union expects the first argument to be an array.'); } var len = arguments.length; var i = 0; while (++i < len) { var arg = arguments[i]; if (!arg) continue; if (!Array.isArray(arg)) { arg = [arg]; } for (var j = 0; j < arg.length; j++) { var ele = arg[j]; if (init.indexOf(ele) >= 0) { continue; } init.push(ele); } } return init; }; arr-union-3.1.0/package.json000066400000000000000000000027051266305320400157200ustar00rootroot00000000000000{ "name": "arr-union", "description": "Combines a list of arrays, returning a single array with unique values, using strict equality for comparisons.", "version": "3.1.0", "homepage": "https://github.com/jonschlinkert/arr-union", "author": "Jon Schlinkert (https://github.com/jonschlinkert)", "repository": "jonschlinkert/arr-union", "bugs": { "url": "https://github.com/jonschlinkert/arr-union/issues" }, "license": "MIT", "files": [ "index.js" ], "main": "index.js", "engines": { "node": ">=0.10.0" }, "scripts": { "test": "mocha" }, "devDependencies": { "ansi-bold": "^0.1.1", "array-union": "^1.0.1", "array-unique": "^0.2.1", "benchmarked": "^0.1.4", "gulp-format-md": "^0.1.7", "minimist": "^1.1.1", "mocha": "*", "should": "*" }, "keywords": [ "add", "append", "array", "arrays", "combine", "concat", "extend", "union", "uniq", "unique", "util", "utility", "utils" ], "verb": { "run": true, "toc": false, "layout": "default", "tasks": [ "readme" ], "plugins": [ "gulp-format-md" ], "related": { "list": [ "arr-diff", "arr-flatten", "arr-filter", "arr-map", "arr-pluck", "arr-reduce", "array-unique" ] }, "reflinks": [ "verb", "array-union" ], "lint": { "reflinks": true } } } arr-union-3.1.0/test.js000066400000000000000000000026001266305320400147410ustar00rootroot00000000000000/*! * arr-union * * Copyright (c) 2014-2015, Jon Schlinkert. * Licensed under the MIT License. */ 'use strict'; /* deps:mocha */ var path = require('path'); var argv = require('minimist')(process.argv.slice(2)); var should = require('should'); var union = require('./'); if (argv._.length) { union = require(path.resolve('benchmark/code/' + argv.code + '.js')); } describe('union', function() { it('should add elements to the original array:', function() { var arr = ['a']; union(arr, ['b', 'c'], ['a'], ['b', 'c'], ['d', 'e', 'f']).sort() arr.should.eql(['a', 'b', 'c', 'd', 'e', 'f'].sort()); }); it('should union all elements in the given arrays:', function() { union(['a'], ['b', 'c'], ['d', 'e', 'f']).sort().should.eql(['a', 'b', 'c', 'd', 'e', 'f'].sort()); }); it('should ignore falsey values', function() { union(['a'], undefined, ['d', 'e', 'f']).sort().should.eql(['a', 'd', 'e', 'f'].sort()); }); it('should arrayify non-array values', function() { union(['a'], 'cde', ['d', 'e', 'f']).sort().should.eql(['a', 'cde', 'd', 'e', 'f'].sort()); }); it('should uniquify elements from additional arrays:', function() { var arr = ['a', 'b', 'c']; var res = union(arr, ['b', 'c'], ['a'], ['b', 'c'], ['d', 'e', 'f']).sort() res.should.eql(['a', 'b', 'c', 'd', 'e', 'f'].sort()); }); });