Skip to main content
Module

x/pazza/mod.ts>many

Parser combinators library designed for Deno, but also works on browsers and Node.js.
Go to Latest
function many
import { many } from "https://deno.land/x/pazza@v0.3.0/mod.ts";

Repeat them embedded parser with "min" times at minimum and "max" times at maximum.

If repeat times is lower than minimum value, it will produce a parsing error. If repeat times reaches maximum value, it will stop parsing and return parsed output.

many(alpha(), 1, 2)("").ok === false;
many(alpha(), 1, 2)("a").output; // ==> ["a"]
many(alpha(), 1, 2)("ab").output; // ==> ["a", "b"]
many(alpha(), 1, 2)("abc").output; // ==> ["a", "b"]
many(alpha(), 1, 2)("abc").input === "c";

Type Parameters

T
E
I extends Input
CtxIn
CtxOut
Min extends number
Max extends number

Parameters

parser: IParser<T, E, I, CtxIn, CtxOut>

embedded parser

min: Min

minimum times (inclusive)

max: Max

maximum times (inclusive)

Returns

NeverFailOnZeroCountParser<Min, T, ErrorKind.Many, I, CtxIn, CtxOut>