type-alias / @typed/router/Parser

Result

A parsed value paired with the unconsumed string suffix.

Package version
1.0.0-beta.13
Category
Parser contracts
Since
1.0.0

Import

import type { Result } from "@typed/router/Parser";

Signatures

export type Result<Value, Rest extends string> = readonly [
    value: Value,
    rest: Rest
];

Why

Every parser can compose without hiding partial consumption.

Ownership and lifetime

Result is a compile-time tuple contract; neither the parsed value nor remaining-input type creates a runtime allocation.

Examples

import type { Parse, Parser } from "@typed/router/Parser"

type Parsed = Parse<Parser.String<"users">, "users/42">
// readonly ["users", "/42"]

Source