Skip to content

Commit 657279f

Browse files
committed
Pull module.exports to top of file
1 parent ba7c39f commit 657279f

File tree

1 file changed

+9
-4
lines changed

1 file changed

+9
-4
lines changed

array-flatten.js

+9-4
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,10 @@
11
'use strict'
22

3+
/**
4+
* Expose `arrayFlatten`.
5+
*/
6+
module.exports = arrayFlatten
7+
38
/**
49
* Recursive flatten function with depth.
510
*
@@ -8,12 +13,12 @@
813
* @param {Number} depth
914
* @return {Array}
1015
*/
11-
function flattenDepth (array, result, depth) {
16+
function flattenWithDepth (array, result, depth) {
1217
for (var i = 0; i < array.length; i++) {
1318
var value = array[i]
1419

1520
if (depth > 0 && Array.isArray(value)) {
16-
flattenDepth(value, result, depth - 1)
21+
flattenWithDepth(value, result, depth - 1)
1722
} else {
1823
result.push(value)
1924
}
@@ -50,10 +55,10 @@ function flattenForever (array, result) {
5055
* @param {Number} depth
5156
* @return {Array}
5257
*/
53-
module.exports = function (array, depth) {
58+
function arrayFlatten (array, depth) {
5459
if (depth == null) {
5560
return flattenForever(array, [])
5661
}
5762

58-
return flattenDepth(array, [], depth)
63+
return flattenWithDepth(array, [], depth)
5964
}

0 commit comments

Comments
 (0)