mirror of
https://github.com/YunoHost/doc.git
synced 2024-09-03 20:06:26 +02:00
11 lines
247 B
JavaScript
11 lines
247 B
JavaScript
|
module.exports = function flat(array) {
|
||
|
let result = [];
|
||
|
array.forEach((a) => {
|
||
|
result.push(a);
|
||
|
if (Array.isArray(a.children)) {
|
||
|
result = result.concat(flat(a.children));
|
||
|
}
|
||
|
});
|
||
|
return result;
|
||
|
};
|