Skip to content

Type Alias: Parser<T> ​

ts
type Parser<T> = object;

Defined in: parser/parsers.ts:31

Turns the string a source holds into a value and back. It determines the type of the ref a composable returns.

Type Parameters ​

Type Parameter
T

Properties ​

parse ​

ts
parse: (raw) => T | null;

Defined in: parser/parsers.ts:33

Returns the value, or null for a string the parser does not accept.

Parameters ​

ParameterType
rawstring

Returns ​

T | null


serialize ​

ts
serialize: (value) => string;

Defined in: parser/parsers.ts:35

Returns the string the source holds.

Parameters ​

ParameterType
valueT

Returns ​

string


withDefault ​

ts
withDefault: (value) => ParserWithDefault<T>;

Defined in: parser/parsers.ts:40

Returns a new parser with a default, so the ref never reads the missing value. The default applies to a missing value and to a string the parser does not accept.

Parameters ​

ParameterType
valueDefaultValue<T>

Returns ​

ParserWithDefault<T>

Released under the MIT License.