Skip to content

Latest commit

 

History

History
29 lines (17 loc) · 1.07 KB

prsc.codepoints.md

File metadata and controls

29 lines (17 loc) · 1.07 KB

Home > prsc > codepoints

codepoints() function

Creates a Parser that skips code points while the given predicate returns true.

This counts in unicode characters (code points), not UTF-16 code units.

This acts like starConsumed(codepoint(isMatch, [])) if expected is not set, or as plusConsumed(codepoint(isMatch, expected)) if it is, but is much more efficient than either of those combinations.

Signature:

export declare function codepoints(isMatch: (codepoint: number) => boolean, expected?: string[]): Parser<void>;

Parameters

Parameter Type Description
isMatch (codepoint: number) => boolean callback called for each codepoint, should return whether that matches
expected string[] (Optional) expected strings to return if the first codepoint does not match

Returns:

Parser<void>