We needed a way to parse and emit key=value log lines without bloating the bundle. This handles the quoting edge cases. The single real gotcha with logfmt is preserving spaces inside quoted values without breaking the tokenizer. This implementation gets that right.
The TypeScript Logfmt Parser relies entirely on the standard library. You install nothing.
logfmt.ts
Look at the test file next to the source code. It demonstrates the exact parsing behavior for those tricky escaped strings.