Socket
Socket
Sign inDemoInstall

arr-flatten

Package Overview
Dependencies
0
Maintainers
1
Versions
8
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

Comparing version 1.0.1 to 1.0.2

20

index.js
/*!
* arr-flatten <https://github.com/jonschlinkert/arr-flatten>
*
* Copyright (c) 2014-2015, Jon Schlinkert.
* Licensed under the MIT License.
* Copyright (c) 2014-2015, 2017, Jon Schlinkert.
* Released under the MIT License.
*/

@@ -14,15 +14,15 @@

function flat(arr, res) {
function flat(arr, acc) {
var len = arr.length;
var i = -1;
var idx = -1;
while (len--) {
var cur = arr[++i];
while (++idx < len) {
var cur = arr[idx];
if (Array.isArray(cur)) {
flat(cur, res);
flat(cur, acc);
} else {
res.push(cur);
acc.push(cur);
}
}
return res;
}
return acc;
}
{
"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.0.2",
"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)",
"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": [

@@ -29,12 +20,19 @@ "index.js"

"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",
"m_flattened": "^1.0.1",
"utils-flatten": "^1.0.0",
"write": "^0.3.3"
},

@@ -51,3 +49,17 @@ "keywords": [

"recursively"
]
],
"verb": {
"toc": false,
"layout": "default",
"tasks": [
"readme"
],
"plugins": [
"gulp-format-md"
],
"lint": {
"reflinks": true
}
},
"dependencies": {}
}

@@ -1,16 +0,41 @@

# 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) [![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. 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 with [yarn](https://yarnpkg.com):
```bash
```sh
$ yarn add 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']
```
## Benchmarks
This library versus [array-flatten](https://github.com/blakeembrey/array-flatten), on April 14, 2017:
```
#1: large.js

@@ -27,48 +52,53 @@ arr-flatten.js x 487,030 ops/sec ±0.67% (92 runs sampled)

array-flatten.js x 3,683,173 ops/sec ±0.79% (97 runs sampled)
```
## Run tests
**Run the benchmarks**
Install dev dependencies:
```bash
npm i -d && npm test
$ npm run benchmarks
```
## 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
### Contributing
## Usage
Pull requests and stars are always welcome. For bugs and feature requests, [please create an issue](../../issues/new).
```js
var flatten = require('arr-flatten');
### Building docs
flatten(['a', ['b', ['c']], 'd', ['e']]);
//=> ['a', 'b', 'c', 'd', 'e']
_(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
_This file was generated by [verb-generate-readme](https://github.com/verbose/verb-generate-readme), v0.5.0, on April 14, 2017._

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc