You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
17 lines
316 B
17 lines
316 B
2 years ago
|
var isArr = require('./isArr');
|
||
|
exports = function(arr) {
|
||
|
return flat(arr, []);
|
||
|
};
|
||
|
function flat(arr, res) {
|
||
|
var len = arr.length,
|
||
|
i = -1,
|
||
|
cur;
|
||
|
while (len--) {
|
||
|
cur = arr[++i];
|
||
|
isArr(cur) ? flat(cur, res) : res.push(cur);
|
||
|
}
|
||
|
return res;
|
||
|
}
|
||
|
|
||
|
module.exports = exports;
|