6
* Simplifies the token stream to ease the matching with the expected token stream.
8
* * Strings are kept as-is
9
* * In arrays each value is transformed individually
10
* * Values that are empty (empty arrays or strings only containing whitespace)
13
* @param {Array} tokenStream
14
* @returns {Array.<string[]|Array>}
16
simplify: function (tokenStream) {
17
if (Array.isArray(tokenStream)) {
19
.map(this.simplify.bind(this))
20
.filter(function (value) {
21
return !(Array.isArray(value) && !value.length) && !(typeof value === "string" && !value.trim().length);
25
else if (typeof tokenStream === "object") {
26
return [tokenStream.type, this.simplify(tokenStream.content)];