many
many combinator applies parser zero or more times. Returns an array of the returned values of parser. This combinator never fails on its own and returns an empty list if nothing matched, but a committed failure from parser propagates instead of ending the loop, and the cursor rewinds to where the combinator started. A success that consumes no input ends the loop and isn't collected, so the combinator always terminates.
Usage
ts
const Parser = many(string('+'))Success
ts
run(Parser).with('+++')
{
isOk: true,
start: 0,
end: 3,
pos: 3,
value: [ '+', '+', '+' ]
}Success
ts
run(Parser).with('---')
{
isOk: true,
start: 0,
end: 0,
pos: 0,
value: []
}