src/parser.js
function prepareTokens(tokens) {
    let result = [];
    let lastToken = null;
    tokens.forEach(token => {
        let newToken = null;
        if (token.type === "text") {
            let value = token.value.replace(GRE_WS, " ").trim();
            if (value !== "") {
                if (lastToken && lastToken.type === "text") {
                    lastToken.value += value;
                } else {
                    newToken = { type: "text", start: token.start, value };
                }
            }
        } else if (token.type !== "comment") {
            newToken = token;
        }
        if (newToken) {
            result.push(newToken);
            lastToken = newToken;
        }
    });
    result.push({ type: "$" });
    return result;
}
function prepareTokens(tokens) {
    let result = [];
    let lastToken = null;
    tokens.forEach(token => {
        let newToken = null;
        if (token.type === "text") {
            let value = token.value.replace(GRE_WS, " ").trim();
            if (value !== "") {
                if (lastToken && lastToken.type === "text") {
                    lastToken.value += value;
                } else {
                    newToken = { type: "text", start: token.start, value };
                }
            }
        } else if (token.type !== "comment") {
            newToken = token;
        }
        if (newToken) {
            result.push(newToken);
            lastToken = newToken;
        }
    });
    result.push({ type: "$" });
    return result;
}
array => array