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.
23 lines
389 B
23 lines
389 B
const { isString } = require('../../utils/validateType');
|
|
|
|
module.exports = function createFlatOrder(order) {
|
|
const flatOrder = [];
|
|
|
|
appendGroup(order);
|
|
|
|
function appendGroup(items) {
|
|
items.forEach((item) => appendItem(item));
|
|
}
|
|
|
|
function appendItem(item) {
|
|
if (isString(item)) {
|
|
flatOrder.push(item);
|
|
|
|
return;
|
|
}
|
|
|
|
appendGroup(item.properties);
|
|
}
|
|
|
|
return flatOrder;
|
|
};
|
|
|