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 0.1.0 to 0.2.0

benchmark/check.js

27

.verbrc.md

@@ -1,4 +0,1 @@

---
tags: ['verb-tag-jscomments']
---
# {%= name %} {%= badge("fury") %}

@@ -8,5 +5,10 @@

## Install
{%= include("install") %}
Why another flatten utility? Because this one is faster.
## Run benchmarks
```bash
node benchmark
```
## Run tests

@@ -18,13 +20,16 @@

## Install
{%= include("install-npm", {save: true}) %}
{%= include("install-bower", {save: true}) %}
## Usage
```js
var arrayFlatten = require('{%= name %}');
console.log(arrayFlatten('abc'));
//=> ['a', 'b', 'c'];
var flatten = require('{%= name %}');
flatten(['a', ['b', ['c']], 'd', ['e']]);
//=> ['a', 'b', 'c', 'd', 'e']
```
## API
{%= jscomments("index.js") %}
## Author

@@ -31,0 +36,0 @@ {%= include("author") %}

@@ -10,10 +10,20 @@ /*!

module.exports = function () {
var args = [].slice.call(arguments);
module.exports = function (arr) {
return flatten(arr, []);
};
do {
args = [].concat.apply([], args);
} while (args.some(Array.isArray));
function flatten(arr, res) {
var len = arr.length;
var num = 0;
return args;
};
while (len--) {
var i = num++;
if (Array.isArray(arr[i])) {
flatten(arr[i], res);
} else {
res.push(arr[i]);
}
}
return res;
}
{
"name": "arr-flatten",
"description": "Recursively flatten an array or arrays.",
"version": "0.1.0",
"description": "Recursively flatten an array or arrays. This is the fastest implementation of array flatten.",
"version": "0.2.0",
"homepage": "https://github.com/jonschlinkert/arr-flatten",

@@ -31,2 +31,8 @@ "author": {

"devDependencies": {
"array-flatten": "^1.0.0",
"array-slice": "^0.2.2",
"benchmarked": "^0.1.3",
"chalk": "^0.5.1",
"glob": "^4.0.6",
"kind-of": "^0.1.2",
"mocha": "*",

@@ -51,2 +57,2 @@ "should": "^4.0.4",

]
}
}

@@ -14,5 +14,9 @@ /*!

describe('flatten', function () {
it('should array flatten', function () {
flatten(['a', ['b', ['c']]], ['d', ['e']]).should.eql(['a', 'b', 'c', 'd', 'e']);
it('should flatten nested arrays:', function () {
flatten(['a', 'b', ['c'], 'd', ['e']]).should.eql(['a', 'b', 'c', 'd', 'e']);
});
it('should flatten deeply nested arrays:', function () {
flatten(['a', [[[[[[[['b', [['c']]]]]], 'd', ['e']]]]]]).should.eql(['a', 'b', 'c', 'd', 'e']);
});
});

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