UNPKG

parjs

Version:

A parser-combinator library for JavaScript.

23 lines (22 loc) 1.17 kB
/** * @module parjs/combinators */ /** */ import { UserState } from "../state"; import { ImplicitParjser, ParjsCombinator } from "../../index"; /** * Tries to apply the source parser repeatedly until `till` succeeds. Yields * the results of the source parser in an array. * @param till The parser that indicates iteration should stop. * @param project * fails softly. Defaults to false. */ export declare function manyTill<TSource, TTill = any, TResult = TSource[]>(till: ImplicitParjser<TTill>, project?: (source: TSource[], till: TTill, user: UserState) => TResult): ParjsCombinator<TSource, TResult>; /** * Applies `start` and then repeatedly applies the source parser until * `pTill` succeeds. Similar to a mix of `between` and `manyTill`. * @param start The initial parser to apply. * @param pTill The terminator. * @param projection Optionally, a projection to apply on the captured results. */ export declare function manyBetween<TSource, TTill = any, TResult = TSource[]>(start: ImplicitParjser<any>, pTill?: ImplicitParjser<TTill>, projection?: (sources: TSource[], till: TTill, state: UserState) => TResult): ParjsCombinator<TSource, TResult>;