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.
22 lines
519 B
22 lines
519 B
import isArray from './is-array';
|
|
/**
|
|
* Flattens `array` a single level deep.
|
|
*
|
|
* @param {Array} arr The array to flatten.
|
|
* @return {Array} Returns the new flattened array.
|
|
* @example
|
|
*
|
|
* flatten([1, [2, [3, [4]], 5]]); // => [1, 2, [3, [4]], 5]
|
|
*/
|
|
var flatten = function (arr) {
|
|
if (!isArray(arr)) {
|
|
return [];
|
|
}
|
|
var rst = [];
|
|
for (var i = 0; i < arr.length; i++) {
|
|
rst = rst.concat(arr[i]);
|
|
}
|
|
return rst;
|
|
};
|
|
export default flatten;
|
|
//# sourceMappingURL=flatten.js.map
|