function CompileText(ast) { let str = ""; const mapper = node => { node.forEach(element => { if (typeof element === "string") { str = str + element; } else if (typeof element === "object") { let result = ""; if (element.type === "url") { result = mapper(element.children); str += mapper(element.children) + " " + element.url; } else { result = mapper(element.children); str = str + result; } } }); return ""; }; mapper(ast); return str; } module.exports = CompileText;