Rebasely Beta: data may be purged

justintypescript-ultra-strict Public

TypeScript · 27 lines · 885 B · at 9c48a39

export type QueryErrorKind = "malformed" | "missing" | "not_integer" | "out_of_range";export class QueryError extends Error {  /** Set for "malformed": the parameter name that was requested. */  readonly param?: string;  /** Set for "not_integer": the decoded value. */  readonly raw?: string;  /** Set for "out_of_range": the parsed number. */  readonly value?: number;  constructor(    public readonly kind: QueryErrorKind,    detail: { param?: string; raw?: string; value?: number } = {},  ) {    super(kind);    Object.assign(this, detail);  }}/** Returns undefined when the parameter is absent. Throws QueryError ("malformed"). */export function getParam(query: string, name: string): string | undefined {  // TODO}/** Throws QueryError. */export function getIntParam(query: string, name: string, range: { min: number; max: number }): number {  // TODO}