2016-10-10 03:43:44 +02:00
|
|
|
/*!
|
|
|
|
* arr-flatten <https://github.com/jonschlinkert/arr-flatten>
|
|
|
|
*
|
2017-08-14 05:01:11 +02:00
|
|
|
* Copyright (c) 2014-2017, Jon Schlinkert.
|
2017-04-20 03:09:25 +02:00
|
|
|
* Released under the MIT License.
|
2016-10-10 03:43:44 +02:00
|
|
|
*/
|
|
|
|
|
|
|
|
'use strict';
|
|
|
|
|
2017-08-14 05:01:11 +02:00
|
|
|
module.exports = function (arr) {
|
2016-10-10 03:43:44 +02:00
|
|
|
return flat(arr, []);
|
|
|
|
};
|
|
|
|
|
2017-08-14 05:01:11 +02:00
|
|
|
function flat(arr, res) {
|
|
|
|
var i = 0, cur;
|
2016-10-10 03:43:44 +02:00
|
|
|
var len = arr.length;
|
2017-08-14 05:01:11 +02:00
|
|
|
for (; i < len; i++) {
|
|
|
|
cur = arr[i];
|
|
|
|
Array.isArray(cur) ? flat(cur, res) : res.push(cur);
|
2016-10-10 03:43:44 +02:00
|
|
|
}
|
2017-08-14 05:01:11 +02:00
|
|
|
return res;
|
2017-04-20 03:09:25 +02:00
|
|
|
}
|