open-radix-trie
v2.3.4
Published
Radix trie implementation with partial lookups and extensible paths.
Downloads
4
Readme
open-radix-trie
Radix trie implementation with partial lookups and extensible paths.
Usage
import { OpenRadixTrie } from 'open-radix-trie'
API
OpenRadixTrie
class OpenRadixTrie<
TValue,
TContext extends Record<keyof TContext, ExtensiblePathComponentMaker> = any
>
A radix trie that matches the largest prefix of a string that matches its nodes.
xerpath is used for routing.
set
(path: ExtensiblePath<TContext> | string, value: TValue | undefined): void
Inserts, updates, or deletes the value of the data structure at the specified path.
Note that no two custom matchers are considered equal and will always result in an insertion.
Parameters:
- path - The path to update.
- value - The value. If
undefined
, the value is removed from the data structure.
get
(path: string): { value: TValue | undefined; args: any[]; remainingPath: string }
Gets the value of the data structure at the specified path.
Parameters:
- path
buildPath
(path: ExtensiblePath<TContext> | string): (string | ExtensiblePathComponent)[]
delete
(path: ExtensiblePath<TContext> | string): boolean
entries, Symbol.iterator
(): IterableIterator<[(string | ExtensiblePathComponent)[], TValue]>
keys
(): IterableIterator<(string | ExtensiblePathComponent)[]>
values
(): IterableIterator<TValue>
clear
(): void
forEach
(callbackFn: (value: TValue, key: (string | ExtensiblePathComponent)[], trie: this) => void, thisArg?: any)
has
(path: string): boolean