open-radix-trie
TypeScript icon, indicating that this package has built-in type declarations

2.3.4 • Public • Published

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

Readme

Keywords

Package Sidebar

Install

npm i open-radix-trie

Weekly Downloads

0

Version

2.3.4

License

MIT

Unpacked Size

64.8 kB

Total Files

29

Last publish

Collaborators

  • seangenabe