array-flatten
Advanced tools
Comparing version 1.0.0 to 1.0.1
@@ -9,8 +9,6 @@ /** | ||
*/ | ||
var flatten = function (array, result, depth) { | ||
depth--; | ||
function flatten (array, result, depth) { | ||
for (var i = 0; i < array.length; i++) { | ||
if (depth > -1 && Array.isArray(array[i])) { | ||
flatten(array[i], result, depth); | ||
if (depth > 0 && Array.isArray(array[i])) { | ||
flatten(array[i], result, depth - 1); | ||
} else { | ||
@@ -22,3 +20,3 @@ result.push(array[i]); | ||
return result; | ||
}; | ||
} | ||
@@ -25,0 +23,0 @@ /** |
{ | ||
"name": "array-flatten", | ||
"version": "1.0.0", | ||
"version": "1.0.1", | ||
"description": "Flatten a multi-dimensional array.", | ||
"main": "array-flatten.js", | ||
"files": [ | ||
"array-flatten.js", | ||
"LICENSE" | ||
], | ||
"scripts": { | ||
@@ -15,5 +19,10 @@ "test": "istanbul cover _mocha -- -R spec" | ||
"array", | ||
"flatten" | ||
"flatten", | ||
"arguments" | ||
], | ||
"author": "Blake Embrey", | ||
"author": { | ||
"name": "Blake Embrey", | ||
"email": "hello@blakeembrey.com", | ||
"url": "http://blakeembrey.me" | ||
}, | ||
"license": "MIT", | ||
@@ -25,5 +34,6 @@ "bugs": { | ||
"devDependencies": { | ||
"istanbul": "^0.2.6", | ||
"mocha": "^1.18.0", | ||
"istanbul": "^0.2.6" | ||
"pre-commit": "0.0.9" | ||
} | ||
} |
@@ -6,5 +6,4 @@ # Array Flatten | ||
[![Test coverage][coveralls-image]][coveralls-url] | ||
[![Gittip][gittip-image]][gittip-url] | ||
Flatten an array of nested arrays into a single flat array. | ||
Flatten an array of nested arrays into a single flat array. Accepts an optional depth argument. | ||
@@ -27,2 +26,6 @@ ## Installation | ||
//=> [1, 2, 3, [4, [5], 6], 7, 8, 9] | ||
(function () { | ||
flatten(arguments); //=> [1, 2, 3] | ||
})(1, [2, 3]); | ||
``` | ||
@@ -40,3 +43,1 @@ | ||
[coveralls-url]: https://coveralls.io/r/blakeembrey/array-flatten?branch=master | ||
[gittip-image]: https://img.shields.io/gittip/blakeembrey.svg?style=flat | ||
[gittip-url]: https://www.gittip.com/blakeembrey |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
41
3727
3
4
31