Options
All
  • Public
  • Public/Protected
  • All
Menu

xradix

Index

Type aliases

KeyMatch

KeyMatch<T>: { depth: number; edges: RadixNodeEdges<T>; hasValue: boolean; key: string; value: T | undefined }
property

depth

property

key

property

hasValue

property

value

property

edges

Type parameters

  • T

Type declaration

  • depth: number
  • edges: RadixNodeEdges<T>
  • hasValue: boolean
  • key: string
  • value: T | undefined

Pruner

Pruner<T>: (depth: number, key: string, hasValue: boolean, value: T, edges: RadixNodeEdges<T>) => boolean
param

the depth of the current node from the searchRoot

param

the key associated with the current node

param

whether or not there is a value associated to the key of the current node

param

the value associated to the key of the current node

param

edges to the child nodes

returns

false to prune the node, true to keep it and its descendants in the search

Type parameters

  • T

Type declaration

    • (depth: number, key: string, hasValue: boolean, value: T, edges: RadixNodeEdges<T>): boolean
    • Parameters

      • depth: number
      • key: string
      • hasValue: boolean
      • value: T
      • edges: RadixNodeEdges<T>

      Returns boolean

SearchRootMatch

SearchRootMatch<T>: { extraPrefix: string; searchRoot: RadixNode<T> }
property

extraPrefix

property

searchRoot

Type parameters

  • T

Type declaration

  • extraPrefix: string
  • searchRoot: RadixNode<T>

Functions

decreasingPrefixesOf

  • decreasingPrefixesOf(s: string): IterableIterator<string>
  • Get all prefixes of a given string in descending order of length.

    example

    for (const s of utils.decreasingPrefixesOf("abc")) { console.log(s); // prints "abc", "ab", "a" }

    example

    for (const s of utils.decreasingPrefixesOf("")) { } // loop never entered

    Parameters

    • s: string

    Returns IterableIterator<string>

Const defaultPruner

  • defaultPruner(): true

increasingPrefixesOf

  • increasingPrefixesOf(s: string): IterableIterator<string>
  • Get all prefixes of a given string in ascending order of length.

    example

    for (const s of utils.increasingPrefixesOf("abc")) { console.log(s); // prints "a", "ab", "abc" }

    example

    for (const s of utils.increasingPrefixesOf("")) { } // never enters loops

    Parameters

    • s: string

    Returns IterableIterator<string>

longestSharedPrefix

  • longestSharedPrefix(s1: string, s2: string): string | undefined
  • Get the longest shared prefix of two strings.

    example

    utils.longestSharedPrefix("abc", "ab"); // "ab"

    example

    utils.longestSharedPrefix("abc", "xx"); // undefined

    example

    utils.longestSharedPrefix("abc", "")

    Parameters

    • s1: string

      the first string

    • s2: string

      the second string

    Returns string | undefined

    • the longest shared prefix of s1 and s2, undefined if no shared prefix

Generated using TypeDoc