import {failure, success} from "@http4t/result"; import {PathMatcher} from "../PathMatcher"; import {Parser, ParserPath, ParserResult} from "./index"; class FloatParser implements Parser { parse(pathSegment: string): ParserResult { const parsed = +pathSegment; return Number.isNaN(parsed) ? failure("expected a number") : success(parsed); } unparse(value: number): string { return value.toString(); } } export class FloatPath extends ParserPath { constructor(base: PathMatcher) { super(base, new FloatParser()) } }