Socket
Socket
Sign inDemoInstall

array-flatten

Package Overview
Dependencies
Maintainers
1
Versions
12
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

array-flatten - npm Package Compare versions

Comparing version 1.1.0 to 1.1.1

15

array-flatten.js

@@ -0,2 +1,9 @@

'use strict'
/**
* Expose `arrayFlatten`.
*/
module.exports = arrayFlatten
/**
* Recursive flatten function with depth.

@@ -9,3 +16,3 @@ *

*/
function flattenDepth (array, result, depth) {
function flattenWithDepth (array, result, depth) {
for (var i = 0; i < array.length; i++) {

@@ -15,3 +22,3 @@ var value = array[i]

if (depth > 0 && Array.isArray(value)) {
flattenDepth(value, result, depth - 1)
flattenWithDepth(value, result, depth - 1)
} else {

@@ -53,3 +60,3 @@ result.push(value)

*/
module.exports = function (array, depth) {
function arrayFlatten (array, depth) {
if (depth == null) {

@@ -59,3 +66,3 @@ return flattenForever(array, [])

return flattenDepth(array, [], depth)
return flattenWithDepth(array, [], depth)
}
{
"name": "array-flatten",
"version": "1.1.0",
"version": "1.1.1",
"description": "Flatten an array of nested arrays into a single flat array",

@@ -5,0 +5,0 @@ "main": "array-flatten.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