Options
All
  • Public
  • Public/Protected
  • All
Menu

Package routing

@typed/routing

Useful abstractions for routing

Index

Type aliases

RouteOptions

RouteOptions: { decode?: undefined | ((str: string) => string); encode?: undefined | ((str: string) => string); exact?: undefined | false | true }

Type declaration

  • Optional Readonly decode?: undefined | ((str: string) => string)
  • Optional Readonly encode?: undefined | ((str: string) => string)
  • Optional Readonly exact?: undefined | false | true

RouteParams

RouteParams<A>: A extends Route<infer R> ? R : never

Type parameters

  • A

RouteValue

RouteValue<A>: A extends Route<any, infer R> ? R : never

Type parameters

  • A

Variables

Const combineRoutes

combineRoutes: { <A, B>(routeA: Route<A>, routeB: Route<B>): Route<A & B>; <A>(routeA: Route<A>): <B>(routeB: Route<B>) => Route<A & B> } = curry(__combineRoutes) as {<A extends Record<string, string>, B extends Record<string, string>>(routeA: Route<A>,routeB: Route<B>,): Route<A & B><A extends Record<string, string>>(routeA: Route<A>): <B extends Record<string, string>>(routeB: Route<B>,) => Route<A & B>}

Type declaration

Const map

map: { <A, B, C>(fn: Arity1<B, C>, route: Route<A, B>): Route<A, C>; <B, C>(fn: Arity1<B, C>): <A>(route: Route<A, B>) => Route<A, C> } = curry(__map) as {<A extends Record<string, string>, B, C>(fn: Arity1<B, C>, route: Route<A, B>): Route<A, C><B, C>(fn: Arity1<B, C>): <A extends Record<string, string>>(route: Route<A, B>) => Route<A, C>}

Type declaration

Const nestMatch

nestMatch: { <A, B, C>(route: Route<A, B>, match: Match<Path, C>): Match<Path, keyof [B, C]>; <A, B>(route: Route<A, B>): <C>(match: Match<Path, C>) => Match<Path, keyof [B, C]> } = curry(__nestMatch) as {<A, B, C>(route: Route<A, B>, match: Match<Path, C>): Match<Path, readonly [B, C]><A, B>(route: Route<A, B>): <C>(match: Match<Path, C>) => Match<Path, readonly [B, C]>}

Type declaration

    • <A, B, C>(route: Route<A, B>, match: Match<Path, C>): Match<Path, keyof [B, C]>
    • <A, B>(route: Route<A, B>): <C>(match: Match<Path, C>) => Match<Path, keyof [B, C]>
    • Type parameters

      • A

      • B

      • C

      Parameters

      Returns Match<Path, keyof [B, C]>

    • Type parameters

      • A

      • B

      Parameters

      Returns <C>(match: Match<Path, C>) => Match<Path, keyof [B, C]>

        • <C>(match: Match<Path, C>): Match<Path, keyof [B, C]>
        • Type parameters

          • C

          Parameters

          • match: Match<Path, C>

          Returns Match<Path, keyof [B, C]>

Const stripRouteFromPath

stripRouteFromPath: { (route: Route<any>, path: Path): Path; (route: Route<any>): (path: Path) => Path } = curry(function stripRoute(route: Route<any>, path: Path): Path {return pathJoin([path.replace(basePathFromRoute(path, route), '')])})

Type declaration

Functions

__nestMatch

  • __nestMatch<A, B, C>(route: Route<A, B>, match: Match<Path, C>): Match<Path, keyof [B, C]>

basePathFromRoute

  • basePathFromRoute<A>(path: Path, __namedParameters: { createPath: (params: A, trailingSlash?: undefined | false | true) => Maybe<Path>; match: Match<string & { __TYPE__: Type }, A> }): Path
  • Type parameters

    • A

    Parameters

    • path: Path
    • __namedParameters: { createPath: (params: A, trailingSlash?: undefined | false | true) => Maybe<Path>; match: Match<string & { __TYPE__: Type }, A> }
      • createPath: (params: A, trailingSlash?: undefined | false | true) => Maybe<Path>
          • (params: A, trailingSlash?: undefined | false | true): Maybe<Path>
          • Parameters

            • params: A
            • Optional trailingSlash: undefined | false | true

            Returns Maybe<Path>

      • match: Match<string & { __TYPE__: Type }, A>

    Returns Path

createRoute

  • createRoute<A>(path: string, __namedParameters?: { decode: (str: string) => string; encode: (str: string) => string; exact: boolean }): Route<A>
  • Type parameters

    Parameters

    • path: string
    • Default value __namedParameters: { decode: (str: string) => string; encode: (str: string) => string; exact: boolean } = {}
      • decode: (str: string) => string
          • (str: string): string
          • Parameters

            • str: string

            Returns string

      • encode: (str: string) => string
          • (str: string): string
          • Parameters

            • str: string

            Returns string

      • exact: boolean

    Returns Route<A>

Generated using TypeDoc