Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

flatten-array

Package Overview
Dependencies
Maintainers
1
Versions
7
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

flatten-array - npm Package Compare versions

Comparing version 0.0.1 to 0.0.2

20

index.js
module.exports = flatten;
function flatten(list){
var result;
function flatten (list, result) {
if(!Array.isArray(list)) return list;
result = [];
var i = -1;
var len = list.length;
list.forEach(function(el){
result || (result = []);
if(!Array.isArray(el)) {
return result.push(el);
while (++i < len) {
if (!Array.isArray(list[i])) {
result.push(list[i]);
continue;
}
result.push.apply(result, flatten(el));
flatten(list[i], result);
}
});
return result;
}
{
"name": "flatten-array",
"version": "0.0.1",
"version": "0.0.2",
"description": "Flattens nested arrays.",

@@ -5,0 +5,0 @@ "main": "index.js",

@@ -17,3 +17,4 @@ ## flatten-array

flatten([1, 2, [3, [4, 5], 6], 7])
// => [1, 2, 3, 4, 5, 6, 7]
// => [1, 2, 3, 4, 5, 6, 7]
```
SocketSocket SOC 2 Logo

Product

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

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc