src/packer.js
function packNode(node) {
    if (node.type === "#") {
        return node.text;
    }
    let item = [node.type];
    let hasProps = (Object.keys(node.props).length !== 0);
    if (hasProps) {
        item.push(node.props);
    }
    if (node.children.length === 0) {
        return item;
    }
    if (!hasProps) {
        item.push(0);
    }
    node.children.forEach(child => item.push(packNode(child)));
    return item;
}
function packNode(node) {
    if (node.type === "#") {
        return node.text;
    }
    let item = [node.type];
    let hasProps = (Object.keys(node.props).length !== 0);
    if (hasProps) {
        item.push(node.props);
    }
    if (node.children.length === 0) {
        return item;
    }
    if (!hasProps) {
        item.push(0);
    }
    node.children.forEach(child => item.push(packNode(child)));
    return item;
}
object => (array | string)