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

just-flatten-it

Package Overview
Dependencies
Maintainers
1
Versions
24
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

just-flatten-it - npm Package Compare versions

Comparing version 3.0.0 to 3.1.0

19

index.js

@@ -9,16 +9,17 @@ module.exports = flatten;

function flattenHelper(arr, depth) {
var stack = arr.slice();
var result = [];
var len = arr.length;
for (var i = 0; i < len; i++) {
var elem = arr[i];
while (stack.length) {
var item = stack.pop();
if (Array.isArray(elem) && depth > 0) {
result.push.apply(result, flattenHelper(elem, depth - 1));
if (Array.isArray(item) && depth > 0) {
stack.push.apply(stack, item);
depth--;
} else {
result.push(elem);
result.push(item);
}
}
return result;
return result.reverse();
}

@@ -35,5 +36,3 @@

var optionDepth = typeof depth === 'number' ? depth : Infinity;
return flattenHelper(arr, optionDepth);
return flattenHelper(arr, typeof depth === 'number' ? depth : Infinity);
}
{
"name": "just-flatten-it",
"version": "3.0.0",
"version": "3.1.0",
"description": "return a flattened array",

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

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