colouring-montreal/app/src/frontend/nav/url-param-transform.ts
2021-02-24 07:49:56 +00:00

17 lines
400 B
TypeScript

export interface UrlParamTransform<T> {
fromParam: (x: string) => T;
toParam: (x: T) => string;
}
const identity: <T>(x: T) => T = (x) => x;
export const stringParamTransform: UrlParamTransform<string> = {
fromParam: identity,
toParam: identity
};
export const intParamTransform: UrlParamTransform<number> = {
fromParam: x => parseInt(x, 10),
toParam: x => x.toString()
};