/** * Builds an array of string and something else, and ensures adjacent strings * are merged together. */ export class StringOrTBuilder { public readonly items: Array = []; public push(item: string | T) { const prev = this.items[this.items.length - 1]; if (typeof item === "string" && typeof prev === "string") { this.items[this.items.length - 1] = prev + item; } else { this.items.push(item); } } }