Parser combinators in TypeScript, shown by parsing real ping output (t3.at)
A parser here is a function from a string to a value and the unread remainder. Small ones chain into larger ones with pSeq, pMap and pRepeat, and the typed result is a tuple or object rather than a match array.
The finished example parses the header, per-packet lines and summary of a real ping run into one typed object.