Options
All
  • Public
  • Public/Protected
  • All
Menu

Package history

@typed/history

Useful abstractions for the History API.

Index

Type aliases

HistoryEnv

HistoryEnv<A>: { history: History; location: Location }

Type parameters

  • A

Type declaration

  • Readonly history: History
  • Readonly location: Location

ParsedHref

ParsedHref: { directory: string; file: string; hash: string; host: string; hostname: string; href: string; password: string; pathname: string; port: string; protocol: string; relative: string; search: string; userInfo: string; username: string }

ParsedHref JSON data structure

name

ParsedHref

Type declaration

  • Readonly directory: string
  • Readonly file: string
  • Readonly hash: string
  • Readonly host: string
  • Readonly hostname: string
  • Readonly href: string
  • Readonly password: string
  • Readonly pathname: string
  • Readonly port: string
  • Readonly protocol: string
  • Readonly relative: string
  • Readonly search: string
  • Readonly userInfo: string
  • Readonly username: string

Path

Path: NewType<string, "Path">

Variables

Const isPath

isPath: (value: A) => value is B = isNewType((str: string): str is Path => str.startsWith('/'))

Type declaration

    • (value: A): value is B
    • Parameters

      • value: A

      Returns value is B

Const pathJoin

pathJoin: (...args: ArgsOf<typeof joinPath>) => Path = joinPath as (...args: ArgsOf<typeof joinPath>) => Path

Type declaration

    • Parameters

      • Rest ...args: ArgsOf<typeof joinPath>

      Returns Path

Functions

createHistoryEnv

createServerHistoryEnv

  • createServerHistoryEnv<A>(href?: string): HistoryEnv<A>

parseHref

parseQueries

  • parseQueries<Queries>(location: Location): Readonly<Queries>
  • Parses a Location's query string into an object of key/value pairs.

    name

    parseQueries<Queries extends Record<string, string>>(location: Location): Queries

    example

    import { createEnv, pushUrl, parseQueries } from '@typed/history'

    const { history, location } = createEnv()

    console.log(parseQueries(location)) // logs => {}

    pushUrl('/?q=hello&lang=en', history)

    console.log(parseQueries(location)) // logs => { q: 'hello', lang: 'en' }

    Type parameters

    • Queries: Record<string, string>

    Parameters

    • location: Location

    Returns Readonly<Queries>

pushPath

pushState

Const replacePath

  • replacePath(path: Path): Effects<{ history: History; location: Location }, null>

replaceState

scopeHistoryEnv

  • scopeHistoryEnv<A>(scope: Path, __namedParameters: { history: History; location: Location }): HistoryEnv<A>

wrapInSubscription

Generated using TypeDoc