UNPKG

fp-ts-routing

Version:

A type-safe routing library for TypeScript

55 lines (54 loc) 1.4 kB
/** * @since 0.6.0 */ import { Contravariant1 } from 'fp-ts/lib/Contravariant'; import { RowLacks } from './helpers'; import { Route } from './route'; /** * @category formatters * @since 0.4.0 */ export declare class Formatter<A> { readonly run: (r: Route, a: A) => Route; /** * @since 0.4.0 */ readonly _A: A; constructor(run: (r: Route, a: A) => Route); /** * @since 0.4.0 */ contramap<B>(f: (b: B) => A): Formatter<B>; /** * @since 0.4.0 */ then<B>(that: Formatter<B> & Formatter<RowLacks<B, keyof A>>): Formatter<A & B>; } declare module 'fp-ts/lib/HKT' { interface URItoKind<A> { 'fp-ts-routing/Formatter': Formatter<A>; } } declare const FORMATTER_URI = "fp-ts-routing/Formatter"; type FORMATTER_URI = typeof FORMATTER_URI; /** * @category formatters * @since 0.5.1 */ export declare const formatter: Contravariant1<FORMATTER_URI>; /** * @category formatters * @since 0.5.1 */ export declare const contramap: <A, B>(f: (b: B) => A) => (fa: Formatter<A>) => Formatter<B>; /** * @category formatters * @since 0.6.0 */ export declare const then: <B>(fb: Formatter<B>) => <A>(fa: Formatter<A> & Formatter<RowLacks<A, keyof B>>) => Formatter<A & B>; /** * @category formatters * @since 0.4.0 */ export declare const format: <A>(formatter: Formatter<A>, a: A, encode?: boolean) => string; export {};