[Pkg-javascript-commits] [node-arr-flatten] 01/06: New upstream version 1.1.0

Julien Puydt julien.puydt at laposte.net
Sat Nov 25 16:06:26 UTC 2017


This is an automated email from the git hooks/post-receive script.

jpuydt-guest pushed a commit to branch master
in repository node-arr-flatten.

commit 16ca684f5d659b5eb7f60dafe482d4cc56206d25
Author: Julien Puydt <julien.puydt at laposte.net>
Date:   Sat Nov 25 16:57:15 2017 +0100

    New upstream version 1.1.0
---
 .editorconfig                                      |  16 +--
 .eslintrc.json                                     | 117 +++++++++++++++++++++
 .gitignore                                         |  69 ++++--------
 .jshintrc                                          |  18 ----
 .travis.yml                                        |  17 ++-
 .verb.md                                           |  51 +--------
 LICENSE                                            |   2 +-
 README.md                                          | 103 ++++++++++--------
 appveyor.yml                                       |  28 +++++
 benchmark/check.js                                 |   6 +-
 ...do-while.js => arr-flatten-0.1.0 (do-while).js} |   8 +-
 .../code/{arr-flatten.js => arr-flatten-0.2.0.js}  |   6 --
 .../code/{current.js => arr-flatten-1.0.1.js}      |   0
 benchmark/code/arr-flatten-2.js                    |  25 -----
 benchmark/code/arr-flatten-3.js                    |  25 -----
 benchmark/code/compute-flatten.js                  |   1 +
 benchmark/code/flatit.js                           |   1 +
 benchmark/code/flatten-array.js                    |   1 +
 benchmark/code/flatten.js                          |   1 +
 benchmark/code/just-flatten-it.js                  |   1 +
 benchmark/code/lodash.flattendeep.js               |   1 +
 benchmark/code/m_flattened.js                      |   1 +
 benchmark/code/utils-flatten.js                    |   1 +
 benchmark/code/while-args.js                       |  24 -----
 benchmark/code/while-depth.js                      |  26 -----
 benchmark/code/while-no-depth-check.js             |  25 -----
 benchmark/code/while-no-depth-typeof.js            |  24 -----
 benchmark/fixtures/{large.js => med.js}            |   0
 benchmark/fixtures/{medium.js => small-med.js}     |   0
 benchmark/index.js                                 |   2 +-
 benchmark/libs.js                                  |  24 +++++
 bower.json                                         |  54 +++++++++-
 index.js                                           |  21 ++--
 package.json                                       |  71 +++++++++----
 test.js                                            |  10 +-
 35 files changed, 394 insertions(+), 386 deletions(-)

diff --git a/.editorconfig b/.editorconfig
index 32dd133..818e072 100644
--- a/.editorconfig
+++ b/.editorconfig
@@ -1,4 +1,3 @@
-# http://editorconfig.org
 root = true
 
 [*]
@@ -9,19 +8,6 @@ indent_size = 2
 trim_trailing_whitespace = true
 insert_final_newline = true
 
-[*.json]
-indent_style = space
-indent_size = 2
-
-[*.yml]
-indent_style = space
-indent_size = 2
-
-[*.md]
-indent_style = space
-indent_size = 2
-trim_trailing_whitespace = false
-
-[test/fixtures/*]
+[{**/{actual,fixtures,expected,templates}/**,*.md}]
 trim_trailing_whitespace = false
 insert_final_newline = false
\ No newline at end of file
diff --git a/.eslintrc.json b/.eslintrc.json
new file mode 100644
index 0000000..61e8895
--- /dev/null
+++ b/.eslintrc.json
@@ -0,0 +1,117 @@
+{
+  "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"]
+  }
+}
diff --git a/.gitignore b/.gitignore
index 92139bd..f2a4ab2 100644
--- a/.gitignore
+++ b/.gitignore
@@ -1,53 +1,28 @@
-# Numerous always-ignore extensions
+# always ignore files
 *.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
+*.sublime-*
 
-# Always-ignore dirs
-/bower_components/
-/node_modules/
-/temp/
-/tmp/
-/vendor/
-_gh_pages
+# test related, or directories generated by tests
+test/actual
+actual
+coverage
+.nyc*
 
-# OS or Editor folders
-*.esproj
-*.komodoproject
-.komodotools
-*.sublime-*
-._*
-.cache
-.DS_Store
-.idea
-.project
-.settings
-.tmproj
-nbproject
-Thumbs.db
+# npm
+node_modules
+npm-debug.log
 
-# grunt-html-validation
-validation-status.json
-validation-report.json
+# yarn
+yarn.lock
+yarn-error.log
 
 # misc
-TODO.md
\ No newline at end of file
+_gh_pages
+_draft
+_drafts
+bower_components
+vendor
+temp
+tmp
+TODO.md
+package-lock.json
\ No newline at end of file
diff --git a/.jshintrc b/.jshintrc
deleted file mode 100644
index 6e5a84a..0000000
--- a/.jshintrc
+++ /dev/null
@@ -1,18 +0,0 @@
-{
-  "asi": false,
-  "boss": true,
-  "curly": true,
-  "eqeqeq": true,
-  "eqnull": true,
-  "esnext": true,
-  "immed": true,
-  "latedef": false,
-  "laxcomma": false,
-  "mocha": true,
-  "newcap": true,
-  "noarg": true,
-  "node": true,
-  "sub": true,
-  "undef": true,
-  "unused": true
-}
\ No newline at end of file
diff --git a/.travis.yml b/.travis.yml
index efe94c0..699a13f 100644
--- a/.travis.yml
+++ b/.travis.yml
@@ -1,8 +1,17 @@
 sudo: false
+os:
+  - linux
+  - osx
 language: node_js
 node_js:
-  - "0.10"
-  - "0.12"
-  - "iojs"
+  - node
+  - iojs
+  - '8'
+  - '7'
+  - '6'
+  - '5'
+  - '4'
+  - '0.12'
+  - '0.10'
 git:
-  depth: 10
\ No newline at end of file
+  depth: 10
diff --git a/.verb.md b/.verb.md
index e76b7da..325dba0 100644
--- a/.verb.md
+++ b/.verb.md
@@ -1,43 +1,7 @@
-# {%= name %} {%= badge("fury") %} {%= badge("travis") %}
+## Install
 
-> {%= description %}
-
-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%.
-
-## Run benchmarks
-
-```bash
-npm run benchmarks
-```
-
-Benchmark results comparing this library to [array-flatten]:
-
-```bash
-#1: large.js
-  arr-flatten.js x 487,030 ops/sec ±0.67% (92 runs sampled)
-  array-flatten.js x 347,020 ops/sec ±0.57% (98 runs sampled)
-
-#2: medium.js
-  arr-flatten.js x 1,914,516 ops/sec ±0.76% (94 runs sampled)
-  array-flatten.js x 1,391,661 ops/sec ±0.63% (96 runs sampled)
-
-#3: small.js
-  arr-flatten.js x 5,158,980 ops/sec ±0.85% (94 runs sampled)
-  array-flatten.js x 3,683,173 ops/sec ±0.79% (97 runs sampled)
-```
-
-## Run tests
-
-Install dev dependencies:
-
-```bash
-npm i -d && npm test
-```
-
-{%= include("install-npm", {save: true}) %}
 {%= include("install-bower", {save: true}) %}
 
-
 ## Usage
 
 ```js
@@ -47,15 +11,6 @@ flatten(['a', ['b', ['c']], 'd', ['e']]);
 //=> ['a', 'b', 'c', 'd', 'e']
 ```
 
-## Author
-{%= include("author") %}
-
-## License
-{%= copyright({start: 2014}) %}
-{%= license() %}
-
-***
-
-{%= include("footer") %}
+## Why another flatten utility?
 
-[array-flatten]: https://github.com/blakeembrey/array-flatten
+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%.
diff --git a/LICENSE b/LICENSE
index fa30c4c..3f2eca1 100644
--- a/LICENSE
+++ b/LICENSE
@@ -1,6 +1,6 @@
 The MIT License (MIT)
 
-Copyright (c) 2014-2015, Jon Schlinkert.
+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
diff --git a/README.md b/README.md
index bd696e6..7dc7a97 100644
--- a/README.md
+++ b/README.md
@@ -1,73 +1,86 @@
-# arr-flatten [![NPM version](https://badge.fury.io/js/arr-flatten.svg)](http://badge.fury.io/js/arr-flatten)  [![Build Status](https://travis-ci.org/jonschlinkert/arr-flatten.svg)](https://travis-ci.org/jonschlinkert/arr-flatten) 
+# 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: [...]
 
-> Recursively flatten an array or arrays. This is the fastest implementation of array flatten.
+> Recursively flatten an array or arrays.
 
-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%.
+## Install
 
-## Run benchmarks
+Install with [npm](https://www.npmjs.com/):
 
-```bash
-npm run benchmarks
+```sh
+$ npm install --save arr-flatten
 ```
 
-Benchmark results comparing this library to [array-flatten]:
+## Install
 
-```bash
-#1: large.js
-  arr-flatten.js x 487,030 ops/sec ±0.67% (92 runs sampled)
-  array-flatten.js x 347,020 ops/sec ±0.57% (98 runs sampled)
+Install with [bower](https://bower.io/)
 
-#2: medium.js
-  arr-flatten.js x 1,914,516 ops/sec ±0.76% (94 runs sampled)
-  array-flatten.js x 1,391,661 ops/sec ±0.63% (96 runs sampled)
-
-#3: small.js
-  arr-flatten.js x 5,158,980 ops/sec ±0.85% (94 runs sampled)
-  array-flatten.js x 3,683,173 ops/sec ±0.79% (97 runs sampled)
+```sh
+$ bower install arr-flatten --save
 ```
 
-## Run tests
+## Usage
 
-Install dev dependencies:
+```js
+var flatten = require('arr-flatten');
 
-```bash
-npm i -d && npm test
+flatten(['a', ['b', ['c']], 'd', ['e']]);
+//=> ['a', 'b', 'c', 'd', 'e']
 ```
 
-## Install with [npm](npmjs.org)
+## Why another flatten utility?
 
-```bash
-npm i arr-flatten --save
-```
-### Install with [bower](https://github.com/bower/bower)
+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%.
 
-```bash
-bower install arr-flatten --save
-```
+## About
 
+### Related projects
 
-## Usage
+* [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.")
 
-```js
-var flatten = require('arr-flatten');
+### Contributing
 
-flatten(['a', ['b', ['c']], 'd', ['e']]);
-//=> ['a', 'b', 'c', 'd', 'e']
+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
 ```
 
-## Author
+### 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](http://twitter.com/jonschlinkert) 
 
-## License
-Copyright (c) 2014-2015 Jon Schlinkert  
-Released under the MIT license
+* [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-cli](https://github.com/assemble/verb-cli) on March 11, 2015._
+***
 
-[array-flatten]: https://github.com/blakeembrey/array-flatten
\ No newline at end of file
+_This file was generated by [verb-generate-readme](https://github.com/verbose/verb-generate-readme), v0.6.0, on July 05, 2017._
\ No newline at end of file
diff --git a/appveyor.yml b/appveyor.yml
new file mode 100644
index 0000000..67b5072
--- /dev/null
+++ b/appveyor.yml
@@ -0,0 +1,28 @@
+# 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
diff --git a/benchmark/check.js b/benchmark/check.js
index e45b2e4..2f3ed79 100644
--- a/benchmark/check.js
+++ b/benchmark/check.js
@@ -3,7 +3,7 @@
 var path = require('path');
 var util = require('util');
 var glob = require('glob');
-var chalk = require('chalk');
+var bold = require('ansi-bold');
 
 /**
  * Sanity check
@@ -18,11 +18,11 @@ glob.sync(__dirname + '/code/*.js').forEach(function (fp) {
   var name = path.basename(fp, path.extname(fp));
 
   fixtures.forEach(function (fixture) {
-    console.log(chalk.bold(name) + ':', inspect(fn(require(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, ' ');
-}
\ No newline at end of file
+}
diff --git a/benchmark/code/do-while.js b/benchmark/code/arr-flatten-0.1.0 (do-while).js
similarity index 76%
rename from benchmark/code/do-while.js
rename to benchmark/code/arr-flatten-0.1.0 (do-while).js
index 56666af..c613678 100644
--- a/benchmark/code/do-while.js
+++ b/benchmark/code/arr-flatten-0.1.0 (do-while).js	
@@ -1,9 +1,3 @@
-'use strict';
-
-/**
- * this was used in v0.1.0
- */
-
 module.exports = function () {
   var args = [].slice.call(arguments);
 
@@ -12,4 +6,4 @@ module.exports = function () {
   } while (args.some(Array.isArray));
 
   return args;
-};
\ No newline at end of file
+};
diff --git a/benchmark/code/arr-flatten.js b/benchmark/code/arr-flatten-0.2.0.js
similarity index 85%
rename from benchmark/code/arr-flatten.js
rename to benchmark/code/arr-flatten-0.2.0.js
index 90da257..3c19797 100644
--- a/benchmark/code/arr-flatten.js
+++ b/benchmark/code/arr-flatten-0.2.0.js
@@ -1,9 +1,3 @@
-'use strict';
-
-/**
- * current implementation
- */
-
 module.exports = function (arr) {
   return flatten(arr, []);
 };
diff --git a/benchmark/code/current.js b/benchmark/code/arr-flatten-1.0.1.js
similarity index 100%
rename from benchmark/code/current.js
rename to benchmark/code/arr-flatten-1.0.1.js
diff --git a/benchmark/code/arr-flatten-2.js b/benchmark/code/arr-flatten-2.js
deleted file mode 100644
index 90da257..0000000
--- a/benchmark/code/arr-flatten-2.js
+++ /dev/null
@@ -1,25 +0,0 @@
-'use strict';
-
-/**
- * current implementation
- */
-
-module.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;
-}
diff --git a/benchmark/code/arr-flatten-3.js b/benchmark/code/arr-flatten-3.js
deleted file mode 100644
index 85b0517..0000000
--- a/benchmark/code/arr-flatten-3.js
+++ /dev/null
@@ -1,25 +0,0 @@
-'use strict';
-
-/**
- * current implementation
- */
-
-module.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])) {
-      res.push(arr[i]);
-    } else {
-      flatten(arr[i], res);
-    }
-  }
-  return res;
-}
diff --git a/benchmark/code/compute-flatten.js b/benchmark/code/compute-flatten.js
new file mode 100644
index 0000000..3c91c24
--- /dev/null
+++ b/benchmark/code/compute-flatten.js
@@ -0,0 +1 @@
+module.exports = require('compute-flatten');
diff --git a/benchmark/code/flatit.js b/benchmark/code/flatit.js
new file mode 100644
index 0000000..138b22d
--- /dev/null
+++ b/benchmark/code/flatit.js
@@ -0,0 +1 @@
+module.exports = require('flatit');
diff --git a/benchmark/code/flatten-array.js b/benchmark/code/flatten-array.js
new file mode 100644
index 0000000..e908963
--- /dev/null
+++ b/benchmark/code/flatten-array.js
@@ -0,0 +1 @@
+module.exports = require('flatten-array');
diff --git a/benchmark/code/flatten.js b/benchmark/code/flatten.js
new file mode 100644
index 0000000..07ac89b
--- /dev/null
+++ b/benchmark/code/flatten.js
@@ -0,0 +1 @@
+module.exports = require('flatten');
diff --git a/benchmark/code/just-flatten-it.js b/benchmark/code/just-flatten-it.js
new file mode 100644
index 0000000..33119ca
--- /dev/null
+++ b/benchmark/code/just-flatten-it.js
@@ -0,0 +1 @@
+module.exports = require('just-flatten-it');
diff --git a/benchmark/code/lodash.flattendeep.js b/benchmark/code/lodash.flattendeep.js
new file mode 100644
index 0000000..23c7923
--- /dev/null
+++ b/benchmark/code/lodash.flattendeep.js
@@ -0,0 +1 @@
+module.exports = require('lodash.flattendeep');
diff --git a/benchmark/code/m_flattened.js b/benchmark/code/m_flattened.js
new file mode 100644
index 0000000..8378e68
--- /dev/null
+++ b/benchmark/code/m_flattened.js
@@ -0,0 +1 @@
+module.exports = require('m_flattened');
diff --git a/benchmark/code/utils-flatten.js b/benchmark/code/utils-flatten.js
new file mode 100644
index 0000000..747d3c5
--- /dev/null
+++ b/benchmark/code/utils-flatten.js
@@ -0,0 +1 @@
+module.exports = require('utils-flatten');
diff --git a/benchmark/code/while-args.js b/benchmark/code/while-args.js
deleted file mode 100644
index 686882d..0000000
--- a/benchmark/code/while-args.js
+++ /dev/null
@@ -1,24 +0,0 @@
-'use strict';
-
-var slice = require('array-slice');
-
-module.exports = function () {
-  var arr = slice(arguments);
-  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;
-}
diff --git a/benchmark/code/while-depth.js b/benchmark/code/while-depth.js
deleted file mode 100644
index 55952f1..0000000
--- a/benchmark/code/while-depth.js
+++ /dev/null
@@ -1,26 +0,0 @@
-'use strict';
-
-module.exports = function (arr, depth) {
-  if (depth < 1) {
-    return arr;
-  }
-  return flatten(arr, [], depth || Infinity);
-};
-
-function flatten(arr, res, depth) {
-  depth--;
-
-  var len = arr.length;
-  var num = 0;
-
-  while (len--) {
-    var i = num++;
-
-    if (depth > -1 && Array.isArray(arr[i])) {
-      flatten(arr[i], res, depth);
-    } else {
-      res.push(arr[i]);
-    }
-  }
-  return res;
-}
diff --git a/benchmark/code/while-no-depth-check.js b/benchmark/code/while-no-depth-check.js
deleted file mode 100644
index 3df15de..0000000
--- a/benchmark/code/while-no-depth-check.js
+++ /dev/null
@@ -1,25 +0,0 @@
-'use strict';
-
-module.exports = function (arr) {
-  if (!arr.some(Array.isArray)) {
-    return 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;
-}
diff --git a/benchmark/code/while-no-depth-typeof.js b/benchmark/code/while-no-depth-typeof.js
deleted file mode 100644
index 756e532..0000000
--- a/benchmark/code/while-no-depth-typeof.js
+++ /dev/null
@@ -1,24 +0,0 @@
-'use strict';
-
-var typeOf = require('kind-of');
-
-module.exports = function (arr) {
-  return flatten(arr, []);
-};
-
-function flatten(arr, res) {
-  var len = arr.length;
-  var num = 0;
-
-  while (len--) {
-    var i = num++;
-
-    if (typeOf(arr[i]) === 'array') {
-      flatten(arr[i], res);
-    } else {
-      res.push(arr[i]);
-    }
-  }
-
-  return res;
-}
diff --git a/benchmark/fixtures/large.js b/benchmark/fixtures/med.js
similarity index 100%
rename from benchmark/fixtures/large.js
rename to benchmark/fixtures/med.js
diff --git a/benchmark/fixtures/medium.js b/benchmark/fixtures/small-med.js
similarity index 100%
rename from benchmark/fixtures/medium.js
rename to benchmark/fixtures/small-med.js
diff --git a/benchmark/index.js b/benchmark/index.js
index 7cf8f46..df28878 100644
--- a/benchmark/index.js
+++ b/benchmark/index.js
@@ -4,7 +4,7 @@ var Suite = require('benchmarked');
 var suite = new Suite({
   result: false,
   fixtures: 'fixtures/*.js',
-  add: 'code/{lib*,current}.js',
+  code: 'code/*.js',
   cwd: __dirname
 });
 
diff --git a/benchmark/libs.js b/benchmark/libs.js
new file mode 100644
index 0000000..d50b97d
--- /dev/null
+++ b/benchmark/libs.js
@@ -0,0 +1,24 @@
+'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`);
+  }
+});
diff --git a/bower.json b/bower.json
index af694aa..3a1c78d 100644
--- a/bower.json
+++ b/bower.json
@@ -1,7 +1,59 @@
 {
   "name": "arr-flatten",
-  "version": "0.2.1",
+  "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"
   ]
 }
\ No newline at end of file
diff --git a/index.js b/index.js
index f74e48c..0cb4ea4 100644
--- a/index.js
+++ b/index.js
@@ -1,27 +1,22 @@
 /*!
  * arr-flatten <https://github.com/jonschlinkert/arr-flatten>
  *
- * Copyright (c) 2014-2015, Jon Schlinkert.
- * Licensed under the MIT License.
+ * Copyright (c) 2014-2017, Jon Schlinkert.
+ * Released under the MIT License.
  */
 
 'use strict';
 
-module.exports = function flatten(arr) {
+module.exports = function (arr) {
   return flat(arr, []);
 };
 
 function flat(arr, res) {
+  var i = 0, cur;
   var len = arr.length;
-  var i = -1;
-
-  while (len--) {
-    var cur = arr[++i];
-    if (Array.isArray(cur)) {
-      flat(cur, res);
-    } else {
-      res.push(cur);
-    }
+  for (; i < len; i++) {
+    cur = arr[i];
+    Array.isArray(cur) ? flat(cur, res) : res.push(cur);
   }
   return res;
-}
\ No newline at end of file
+}
diff --git a/package.json b/package.json
index 8d0322d..d2d33e9 100644
--- a/package.json
+++ b/package.json
@@ -1,23 +1,18 @@
 {
   "name": "arr-flatten",
-  "description": "Recursively flatten an array or arrays. This is the fastest implementation of array flatten.",
-  "version": "1.0.1",
+  "description": "Recursively flatten an array or arrays.",
+  "version": "1.1.0",
   "homepage": "https://github.com/jonschlinkert/arr-flatten",
-  "author": {
-    "name": "Jon Schlinkert",
-    "url": "https://github.com/jonschlinkert"
-  },
-  "repository": {
-    "type": "git",
-    "url": "git://github.com/jonschlinkert/arr-flatten.git"
-  },
+  "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": {
-    "type": "MIT",
-    "url": "https://github.com/jonschlinkert/arr-flatten/blob/master/LICENSE"
-  },
+  "license": "MIT",
   "files": [
     "index.js"
   ],
@@ -26,16 +21,25 @@
     "node": ">=0.10.0"
   },
   "scripts": {
-    "test": "mocha",
-    "benchmarks": "node benchmark"
+    "test": "mocha"
   },
   "devDependencies": {
-    "array-flatten": "^1.0.2",
-    "array-slice": "^0.2.2",
-    "benchmarked": "^0.1.3",
-    "chalk": "^0.5.1",
-    "glob": "^4.3.5",
-    "kind-of": "^1.0.0"
+    "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",
@@ -47,5 +51,26 @@
     "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
+    }
+  }
 }
diff --git a/test.js b/test.js
index 9d5b9f0..023221c 100644
--- a/test.js
+++ b/test.js
@@ -1,22 +1,22 @@
 /*!
  * arr-flatten <https://github.com/jonschlinkert/arr-flatten>
  *
- * Copyright (c) 2014-2015, Jon Schlinkert.
+ * Copyright (c) 2014-2017, Jon Schlinkert.
  * Licensed under the MIT License.
  */
 
 'use strict';
 
+require('mocha');
 var assert = require('assert');
 var flatten = require('./');
-var arrFlatten = require('array-flatten');
 
-describe('flatten', function () {
-  it('should flatten nested arrays:', function () {
+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 () {
+  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',  [...]

-- 
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/pkg-javascript/node-arr-flatten.git



More information about the Pkg-javascript-commits mailing list