wallet-core/node_modules/arr-flatten/index.js

23 lines
418 B
JavaScript
Raw Normal View History

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.
* 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;
}