"Hello, world!"{
greeting: "Hello",
who: "world"
}
type Parser<T> = (input: string) => [T, string]
["pIntegernumber10, "string 20 30"]
pHello["Hello", " 100"]
pIgnoreWhitespace[" null", "100"]
pInteger["100", ""]
pHello100["Hello 100["Hello", null, 100]", ""]
pSeq(
pHello,
pIgnoreWhitespace,
pInteger
)Parser<[
string,
null,
number
]>
const pHello100 = pSeq(...)const result = pHello100("Hello 100")
pHello100["Hello 100["Hello", null, 100]", ""]
pGreeting["Hello 100["Hello", null, 100]{
greeting: "Hello",
who: 100
}pMap", ""]
pSeq(pNumber, pSemicolon)["10;[10, ";"]", "20;30;"]
pSeq(pNumber, pSemicolon)["20;[20, ";"]", "30;"]
pSeq(pNumber, pSemicolon)["30;[30, ";"]", ""]
PING 1.1.1.1 (1.1.1.1) 56(84) bytes of data.
64 bytes from 1.1.1.1: icmp_seq=1 ttl=52 time=389 ms
64 bytes from 1.1.1.1: icmp_seq=2 ttl=52 time=68.7 ms
64 bytes from 1.1.1.1: icmp_seq=3 ttl=52 time=47.1 ms
64 bytes from 1.1.1.1: icmp_seq=4 ttl=52 time=48.6 ms
64 bytes from 1.1.1.1: icmp_seq=5 ttl=52 time=85.8 ms
64 bytes from 1.1.1.1: icmp_seq=6 ttl=52 time=84.8 ms
64 bytes from 1.1.1.1: icmp_seq=7 ttl=52 time=87.4 ms
--- 1.1.1.1 ping statistics ---
8 packets transmitted, 7 received, 12.5% packet loss, time 7008ms
rtt min/avg/max/mdev = 47.129/115.880/388.750/112.515 ms
{
header: { targetIp: "1.1.1.1", resolvedIp: "1.1.1.1", icmpPayloadSize: 56, totalPacketSize: 84 },
packets: [
{ byteCount: 64, from: "1.1.1.1", seq: 1, ttl: 52, time: 389 },
{ byteCount: 64, from: "1.1.1.1", seq: 2, ttl: 52, time: 68.7 },
{ byteCount: 64, from: "1.1.1.1", seq: 3, ttl: 52, time: 47.1 },
{ byteCount: 64, from: "1.1.1.1", seq: 4, ttl: 52, time: 48.6 },
{ byteCount: 64, from: "1.1.1.1", seq: 5, ttl: 52, time: 85.8 },
{ byteCount: 64, from: "1.1.1.1", seq: 6, ttl: 52, time: 84.8 },
{ byteCount: 64, from: "1.1.1.1", seq: 7, ttl: 52, time: 87.4 },
],
statistics: {
packetsTransmitted: 8, packetsReceived: 7, packetLoss: 12.5, time: 7008,
rtt: { min: 47.129, avg: 115.88, max: 388.75, mdev: 112.515 },
},
}