pax_global_header00006660000000000000000000000064131272323710014513gustar00rootroot0000000000000052 comment=2f47651a69aa1603b70a3895084952a95791fa7b arr-flatten-1.1.0/000077500000000000000000000000001312723237100137315ustar00rootroot00000000000000arr-flatten-1.1.0/.editorconfig000066400000000000000000000004051312723237100164050ustar00rootroot00000000000000root = true [*] indent_style = space end_of_line = lf charset = utf-8 indent_size = 2 trim_trailing_whitespace = true insert_final_newline = true [{**/{actual,fixtures,expected,templates}/**,*.md}] trim_trailing_whitespace = false insert_final_newline = falsearr-flatten-1.1.0/.eslintrc.json000066400000000000000000000067751312723237100165440ustar00rootroot00000000000000{ "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-flatten-1.1.0/.gitattributes000066400000000000000000000001771312723237100166310ustar00rootroot00000000000000# Enforce Unix newlines * text eol=lf # binaries *.ai binary *.psd binary *.jpg binary *.gif binary *.png binary *.jpeg binaryarr-flatten-1.1.0/.gitignore000066400000000000000000000004401312723237100157170ustar00rootroot00000000000000# always ignore files *.DS_Store *.sublime-* # test related, or directories generated by tests test/actual actual coverage .nyc* # npm node_modules npm-debug.log # yarn yarn.lock yarn-error.log # misc _gh_pages _draft _drafts bower_components vendor temp tmp TODO.md package-lock.jsonarr-flatten-1.1.0/.travis.yml000066400000000000000000000002361312723237100160430ustar00rootroot00000000000000sudo: false os: - linux - osx language: node_js node_js: - node - iojs - '8' - '7' - '6' - '5' - '4' - '0.12' - '0.10' git: depth: 10 arr-flatten-1.1.0/.verb.md000066400000000000000000000005721312723237100152730ustar00rootroot00000000000000## Install {%= include("install-bower", {save: true}) %} ## Usage ```js var flatten = require('{%= name %}'); flatten(['a', ['b', ['c']], 'd', ['e']]); //=> ['a', 'b', 'c', 'd', 'e'] ``` ## Why another flatten utility? I wanted the fastest implementation I could find, with implementation choices that should work for 95% of use cases, but no cruft to cover the other 5%. arr-flatten-1.1.0/LICENSE000066400000000000000000000021001312723237100147270ustar00rootroot00000000000000The MIT License (MIT) Copyright (c) 2014-2017, 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-flatten-1.1.0/README.md000066400000000000000000000072641312723237100152210ustar00rootroot00000000000000# arr-flatten [![NPM version](https://img.shields.io/npm/v/arr-flatten.svg?style=flat)](https://www.npmjs.com/package/arr-flatten) [![NPM monthly downloads](https://img.shields.io/npm/dm/arr-flatten.svg?style=flat)](https://npmjs.org/package/arr-flatten) [![NPM total downloads](https://img.shields.io/npm/dt/arr-flatten.svg?style=flat)](https://npmjs.org/package/arr-flatten) [![Linux Build Status](https://img.shields.io/travis/jonschlinkert/arr-flatten.svg?style=flat&label=Travis)](https://travis-ci.org/jonschlinkert/arr-flatten) [![Windows Build Status](https://img.shields.io/appveyor/ci/jonschlinkert/arr-flatten.svg?style=flat&label=AppVeyor)](https://ci.appveyor.com/project/jonschlinkert/arr-flatten) > Recursively flatten an array or arrays. ## Install Install with [npm](https://www.npmjs.com/): ```sh $ npm install --save arr-flatten ``` ## Install Install with [bower](https://bower.io/) ```sh $ bower install arr-flatten --save ``` ## Usage ```js var flatten = require('arr-flatten'); flatten(['a', ['b', ['c']], 'd', ['e']]); //=> ['a', 'b', 'c', 'd', 'e'] ``` ## Why another flatten utility? I wanted the fastest implementation I could find, with implementation choices that should work for 95% of use cases, but no cruft to cover the other 5%. ## About ### Related projects * [arr-filter](https://www.npmjs.com/package/arr-filter): Faster alternative to javascript's native filter method. | [homepage](https://github.com/jonschlinkert/arr-filter "Faster alternative to javascript's native filter method.") * [arr-union](https://www.npmjs.com/package/arr-union): Combines a list of arrays, returning a single array with unique values, using strict equality… [more](https://github.com/jonschlinkert/arr-union) | [homepage](https://github.com/jonschlinkert/arr-union "Combines a list of arrays, returning a single array with unique values, using strict equality for comparisons.") * [array-each](https://www.npmjs.com/package/array-each): Loop over each item in an array and call the given function on every element. | [homepage](https://github.com/jonschlinkert/array-each "Loop over each item in an array and call the given function on every element.") * [array-unique](https://www.npmjs.com/package/array-unique): Remove duplicate values from an array. Fastest ES5 implementation. | [homepage](https://github.com/jonschlinkert/array-unique "Remove duplicate values from an array. Fastest ES5 implementation.") ### Contributing Pull requests and stars are always welcome. For bugs and feature requests, [please create an issue](../../issues/new). ### Contributors | **Commits** | **Contributor** | | --- | --- | | 20 | [jonschlinkert](https://github.com/jonschlinkert) | | 1 | [lukeed](https://github.com/lukeed) | ### Building docs _(This project's readme.md is generated by [verb](https://github.com/verbose/verb-generate-readme), please don't edit the readme directly. Any changes to the readme must be made in the [.verb.md](.verb.md) readme template.)_ To generate the readme, run the following command: ```sh $ npm install -g verbose/verb#dev verb-generate-readme && verb ``` ### Running tests Running and reviewing unit tests is a great way to get familiarized with a library and its API. You can install dependencies and run tests with the following command: ```sh $ npm install && npm test ``` ### Author **Jon Schlinkert** * [github/jonschlinkert](https://github.com/jonschlinkert) * [twitter/jonschlinkert](https://twitter.com/jonschlinkert) ### License Copyright © 2017, [Jon Schlinkert](https://github.com/jonschlinkert). Released under the [MIT License](LICENSE). *** _This file was generated by [verb-generate-readme](https://github.com/verbose/verb-generate-readme), v0.6.0, on July 05, 2017._arr-flatten-1.1.0/appveyor.yml000066400000000000000000000011441312723237100163210ustar00rootroot00000000000000# Test against this version of Node.js environment: matrix: # node.js - nodejs_version: "7.0" - nodejs_version: "6.0" - nodejs_version: "5.0" - nodejs_version: "4.0" - nodejs_version: "0.12" - nodejs_version: "0.10" # Install scripts. (runs after repo cloning) install: # Get the latest stable version of Node.js - ps: Install-Product node $env:nodejs_version # install modules - npm install # Post-install test scripts. test_script: # Output useful info for debugging. - node --version - npm --version # run tests - npm test # Don't actually build. build: off arr-flatten-1.1.0/benchmark/000077500000000000000000000000001312723237100156635ustar00rootroot00000000000000arr-flatten-1.1.0/benchmark/check.js000066400000000000000000000012421312723237100172750ustar00rootroot00000000000000'use strict'; var path = require('path'); var util = require('util'); var glob = require('glob'); var bold = require('ansi-bold'); /** * Sanity check * * Run to ensure that all fns return the same, correct result. */ var fixtures = glob.sync(__dirname + '/fixtures/l*.js'); glob.sync(__dirname + '/code/*.js').forEach(function (fp) { var fn = require(path.resolve(__dirname, 'code', fp)); var name = path.basename(fp, path.extname(fp)); fixtures.forEach(function (fixture) { console.log(bold(name) + ':', inspect(fn(require(fixture)))); }); }); function inspect(o) { var str = util.inspect(o, {depth: null}); return str.replace(/[\s\n]+/g, ' '); } arr-flatten-1.1.0/benchmark/code/000077500000000000000000000000001312723237100165755ustar00rootroot00000000000000arr-flatten-1.1.0/benchmark/code/arr-flatten-0.1.0 (do-while).js000066400000000000000000000002551312723237100236200ustar00rootroot00000000000000module.exports = function () { var args = [].slice.call(arguments); do { args = [].concat.apply([], args); } while (args.some(Array.isArray)); return args; }; arr-flatten-1.1.0/benchmark/code/arr-flatten-0.2.0.js000066400000000000000000000004501312723237100220040ustar00rootroot00000000000000module.exports = function (arr) { return flatten(arr, []); }; function flatten(arr, res) { var len = arr.length; var num = 0; while (len--) { var i = num++; if (Array.isArray(arr[i])) { flatten(arr[i], res); } else { res.push(arr[i]); } } return res; } arr-flatten-1.1.0/benchmark/code/arr-flatten-1.0.1.js000066400000000000000000000000421312723237100220010ustar00rootroot00000000000000module.exports = require('../..');arr-flatten-1.1.0/benchmark/code/compute-flatten.js000066400000000000000000000000551312723237100222420ustar00rootroot00000000000000module.exports = require('compute-flatten'); arr-flatten-1.1.0/benchmark/code/do-while-slice.js000066400000000000000000000003301312723237100217340ustar00rootroot00000000000000'use strict'; var slice = require('array-slice'); module.exports = function () { var args = slice(arguments); do { args = [].concat.apply([], args); } while (args.some(Array.isArray)); return args; };arr-flatten-1.1.0/benchmark/code/flatit.js000066400000000000000000000000441312723237100204140ustar00rootroot00000000000000module.exports = require('flatit'); arr-flatten-1.1.0/benchmark/code/flatten-array.js000066400000000000000000000000531312723237100217020ustar00rootroot00000000000000module.exports = require('flatten-array'); arr-flatten-1.1.0/benchmark/code/flatten.js000066400000000000000000000000451312723237100205670ustar00rootroot00000000000000module.exports = require('flatten'); arr-flatten-1.1.0/benchmark/code/just-flatten-it.js000066400000000000000000000000551312723237100221650ustar00rootroot00000000000000module.exports = require('just-flatten-it'); arr-flatten-1.1.0/benchmark/code/lib-array-flatten.js000066400000000000000000000000711312723237100224460ustar00rootroot00000000000000'use strict'; module.exports = require('array-flatten');arr-flatten-1.1.0/benchmark/code/lodash.flattendeep.js000066400000000000000000000000601312723237100226730ustar00rootroot00000000000000module.exports = require('lodash.flattendeep'); arr-flatten-1.1.0/benchmark/code/m_flattened.js000066400000000000000000000000511312723237100214110ustar00rootroot00000000000000module.exports = require('m_flattened'); arr-flatten-1.1.0/benchmark/code/utils-flatten.js000066400000000000000000000000531312723237100217240ustar00rootroot00000000000000module.exports = require('utils-flatten'); arr-flatten-1.1.0/benchmark/fixtures/000077500000000000000000000000001312723237100175345ustar00rootroot00000000000000arr-flatten-1.1.0/benchmark/fixtures/med.js000066400000000000000000000011121312723237100206320ustar00rootroot00000000000000module.exports = [[['a', ['b', ['k', ['a', ['b', ['c'], [['a', [['a', ['b', ['k', ['a', ['b', ['c']], ['a', ['x', ['c'], ['a', ['x', ['k']]], ['d', ['z']]]], ['d', ['m']]], ['d', ['e']]]]], ['d', ['e']]], ['b', ['k', ['a', ['b', ['c']], ['a', ['x', ['c'], ['a', ['x', ['k']]], ['d', ['z']]]], ['d', ['m']]], ['d', ['e']]]]], ['d', ['e']]]], ['a', ['x', ['c'], ['a', ['x', ['k']], [['a', ['b', ['k', ['a', ['b', ['c']], ['a', ['x', ['c'], ['a', ['x', ['k']]], ['d', ['z']]]], ['d', ['m']]], ['d', ['e']]]]], ['d', ['e']]]], ['d', ['z']]]], ['d', ['m']]], ['d', ['e']]]]], ['d', ['e']]]];arr-flatten-1.1.0/benchmark/fixtures/small-med.js000066400000000000000000000002411312723237100217420ustar00rootroot00000000000000module.exports = [[['a', ['b', ['k', ['a', ['b', ['c']], ['a', ['x', ['c'], ['a', ['x', ['k']]], ['d', ['z']]]], ['d', ['m']]], ['d', ['e']]]]], ['d', ['e']]]]; arr-flatten-1.1.0/benchmark/fixtures/small.js000066400000000000000000000000701312723237100211770ustar00rootroot00000000000000module.exports = [[['a', ['b', ['c']]], ['d', ['e']]]]; arr-flatten-1.1.0/benchmark/index.js000066400000000000000000000002611312723237100173270ustar00rootroot00000000000000'use strict'; var Suite = require('benchmarked'); var suite = new Suite({ result: false, fixtures: 'fixtures/*.js', code: 'code/*.js', cwd: __dirname }); suite.run(); arr-flatten-1.1.0/benchmark/libs.js000066400000000000000000000007531312723237100171570ustar00rootroot00000000000000'use strict'; var fs = require('fs'); var path = require('path'); var write = require('write'); var cwd = path.join.bind(path, __dirname, 'code'); [ 'compute-flatten', 'flatit', 'flatten', 'flatten-array', 'just-flatten-it', 'lodash.flatten', 'lodash.flattendeep', 'm_flattened', 'reduce-flatten', 'utils-flatten' ].forEach(function(name) { var fp = cwd(name + '.js'); if (!fs.existsSync(fp)) { write.sync(fp, `module.exports = require('${name}');\n`); } }); arr-flatten-1.1.0/bower.json000066400000000000000000000023301312723237100157400ustar00rootroot00000000000000{ "name": "arr-flatten", "version": "1.0.3", "main": [ "index.js" ], "description": "Recursively flatten an array or arrays.", "homepage": "https://github.com/jonschlinkert/arr-flatten", "repository": "jonschlinkert/arr-flatten", "bugs": { "url": "https://github.com/jonschlinkert/arr-flatten/issues" }, "license": "MIT", "files": [ "index.js" ], "devDependencies": { "ansi-bold": "^0.1.1", "array-flatten": "^2.1.1", "array-slice": "^1.0.0", "benchmarked": "^1.0.0", "compute-flatten": "^1.0.0", "flatit": "^1.1.1", "flatten": "^1.0.2", "flatten-array": "^1.0.0", "glob": "^7.1.1", "gulp-format-md": "^0.1.12", "just-flatten-it": "^1.1.23", "lodash.flattendeep": "^4.4.0", "m_flattened": "^1.0.1", "mocha": "^3.2.0", "utils-flatten": "^1.0.0", "write": "^0.3.3" }, "keywords": [ "arr", "array", "elements", "flat", "flatten", "nested", "recurse", "recursive", "recursively" ], "authors": [ "Jon Schlinkert (https://github.com/jonschlinkert)" ], "ignore": [ "actual", "bower_components", "fixtures", "node_modules", "temp", "test", "test.js", "tmp" ] }arr-flatten-1.1.0/index.js000066400000000000000000000006421312723237100154000ustar00rootroot00000000000000/*! * arr-flatten * * Copyright (c) 2014-2017, Jon Schlinkert. * Released under the MIT License. */ 'use strict'; module.exports = function (arr) { return flat(arr, []); }; function flat(arr, res) { var i = 0, cur; var len = arr.length; for (; i < len; i++) { cur = arr[i]; Array.isArray(cur) ? flat(cur, res) : res.push(cur); } return res; } arr-flatten-1.1.0/package.json000066400000000000000000000031061312723237100162170ustar00rootroot00000000000000{ "name": "arr-flatten", "description": "Recursively flatten an array or arrays.", "version": "1.1.0", "homepage": "https://github.com/jonschlinkert/arr-flatten", "author": "Jon Schlinkert (https://github.com/jonschlinkert)", "contributors": [ "Jon Schlinkert (http://twitter.com/jonschlinkert)", "Luke Edwards (https://lukeed.com)" ], "repository": "jonschlinkert/arr-flatten", "bugs": { "url": "https://github.com/jonschlinkert/arr-flatten/issues" }, "license": "MIT", "files": [ "index.js" ], "main": "index.js", "engines": { "node": ">=0.10.0" }, "scripts": { "test": "mocha" }, "devDependencies": { "ansi-bold": "^0.1.1", "array-flatten": "^2.1.1", "array-slice": "^1.0.0", "benchmarked": "^1.0.0", "compute-flatten": "^1.0.0", "flatit": "^1.1.1", "flatten": "^1.0.2", "flatten-array": "^1.0.0", "glob": "^7.1.1", "gulp-format-md": "^0.1.12", "just-flatten-it": "^1.1.23", "lodash.flattendeep": "^4.4.0", "m_flattened": "^1.0.1", "mocha": "^3.2.0", "utils-flatten": "^1.0.0", "write": "^0.3.3" }, "keywords": [ "arr", "array", "elements", "flat", "flatten", "nested", "recurse", "recursive", "recursively" ], "verb": { "toc": false, "layout": "default", "tasks": [ "readme" ], "plugins": [ "gulp-format-md" ], "related": { "list": [ "arr-filter", "arr-union", "array-each", "array-unique" ] }, "lint": { "reflinks": true } } } arr-flatten-1.1.0/test.js000066400000000000000000000032401312723237100152450ustar00rootroot00000000000000/*! * arr-flatten * * Copyright (c) 2014-2017, Jon Schlinkert. * Licensed under the MIT License. */ 'use strict'; require('mocha'); var assert = require('assert'); var flatten = require('./'); describe('flatten', function() { it('should flatten nested arrays:', function() { assert.deepEqual(flatten(['a', 'b', ['c'], 'd', ['e']]), ['a', 'b', 'c', 'd', 'e']); }); it('should flatten deeply nested arrays:', function() { assert.deepEqual(flatten(['a', [[[[[[[['b', [['c']]]]]], 'd', ['e']]]]]]), ['a', 'b', 'c', 'd', 'e']); assert.deepEqual(flatten(['a', 'b', ['c'], 'd', ['e']]), ['a', 'b', 'c', 'd', 'e']); assert.deepEqual(flatten([['a', ['b', ['k', ['a', ['b', ['c'], [['a', [['a', ['b', ['k', ['a', ['b', ['c']], ['a', ['x', ['c'], ['a', ['x', ['k']]], ['d', ['z']]]], ['d', ['m']]], ['d', ['e']]]]], ['d', ['e']]], ['b', ['k', ['a', ['b', ['c']], ['a', ['x', ['c'], ['a', ['x', ['k']]], ['d', ['z']]]], ['d', ['m']]], ['d', ['e']]]]], ['d', ['e']]]], ['a', ['x', ['c'], ['a', ['x', ['k']], [['a', ['b', ['k', ['a', ['b', ['c']], ['a', ['x', ['c'], ['a', ['x', ['k']]], ['d', ['z']]]], ['d', ['m']]], ['d', ['e']]]]], ['d', ['e']]]], ['d', ['z']]]], ['d', ['m']]], ['d', ['e']]]]], ['d', ['e']]]), [ 'a', 'b', 'k', 'a', 'b', 'c', 'a', 'a', 'b', 'k', 'a', 'b', 'c', 'a', 'x', 'c', 'a', 'x', 'k', 'd', 'z', 'd', 'm', 'd', 'e', 'd', 'e', 'b', 'k', 'a', 'b', 'c', 'a', 'x', 'c', 'a', 'x', 'k', 'd', 'z', 'd', 'm', 'd', 'e', 'd', 'e', 'a', 'x', 'c', 'a', 'x', 'k', 'a', 'b', 'k', 'a', 'b', 'c', 'a', 'x', 'c', 'a', 'x', 'k', 'd', 'z', 'd', 'm', 'd', 'e', 'd', 'e', 'd', 'z', 'd', 'm', 'd', 'e', 'd', 'e' ]); }); });