* Returns the pre-serialized ANSI string to transition from one style to * another. Cached by (fromId, toId) — zero allocations after first call * for a given pair.
(fromId: number, toId: number)
| 151 | * for a given pair. |
| 152 | */ |
| 153 | transition(fromId: number, toId: number): string { |
| 154 | if (fromId === toId) return '' |
| 155 | const key = fromId * 0x100000 + toId |
| 156 | let str = this.transitionCache.get(key) |
| 157 | if (str === undefined) { |
| 158 | str = ansiCodesToString(diffAnsiCodes(this.get(fromId), this.get(toId))) |
| 159 | this.transitionCache.set(key, str) |
| 160 | } |
| 161 | return str |
| 162 | } |
| 163 | |
| 164 | /** |
| 165 | * Intern a style that is `base + inverse`. Cached by base ID so |
no test coverage detected