Split `k=v;k=v` honoring `\;` and `\\` escapes. Yields [key, unescapedValue].
(data: string)
| 366 | |
| 367 | /** Split `k=v;k=v` honoring `\;` and `\\` escapes. Yields [key, unescapedValue]. */ |
| 368 | function* splitTabStatusPairs(data: string): Generator<[string, string]> { |
| 369 | let key = '' |
| 370 | let val = '' |
| 371 | let inVal = false |
| 372 | let esc = false |
| 373 | for (const c of data) { |
| 374 | if (esc) { |
| 375 | if (inVal) val += c |
| 376 | else key += c |
| 377 | esc = false |
| 378 | } else if (c === '\\') { |
| 379 | esc = true |
| 380 | } else if (c === ';') { |
| 381 | yield [key, val] |
| 382 | key = '' |
| 383 | val = '' |
| 384 | inVal = false |
| 385 | } else if (c === '=' && !inVal) { |
| 386 | inVal = true |
| 387 | } else if (inVal) { |
| 388 | val += c |
| 389 | } else { |
| 390 | key += c |
| 391 | } |
| 392 | } |
| 393 | if (key || inVal) yield [key, val] |
| 394 | } |
| 395 | |
| 396 | // Output generators |
| 397 |