manyTillOneOf is an optimized version of
manyTill. The manyTill combinator is
slow because it runs the given parser on every character of
the string until it succeeds. However, if you just want to
consume input until you get to a substring, use
manyTillOneOf. It uses indexOf,
which is significantly faster than running a parser over every
character.
Given an array of strings, this parser consumes input until it
hits one of those strings. If none of the strings is found,
the parser will consume all input and return success.
Parameters
stops:
string[]
options:
{ insensitive?: boolean; } = {}
object of optional parameters. { insensitive: boolean }
manyTillOneOf
is an optimized version ofmanyTill
. ThemanyTill
combinator is slow because it runs the given parser on every character of the string until it succeeds. However, if you just want to consume input until you get to a substring, usemanyTillOneOf
. It usesindexOf
, which is significantly faster than running a parser over every character.Given an array of strings, this parser consumes input until it hits one of those strings. If none of the strings is found, the parser will consume all input and return success.