https://github.com/seangenabe/open-radix-trie
Radix trie implementation with partial lookups and extensible paths
https://github.com/seangenabe/open-radix-trie
Last synced: 7 months ago
JSON representation
Radix trie implementation with partial lookups and extensible paths
- Host: GitHub
- URL: https://github.com/seangenabe/open-radix-trie
- Owner: seangenabe
- Created: 2018-02-18T16:44:53.000Z (over 7 years ago)
- Default Branch: master
- Last Pushed: 2019-04-10T10:03:51.000Z (over 6 years ago)
- Last Synced: 2025-03-04T18:41:06.793Z (8 months ago)
- Language: TypeScript
- Size: 193 KB
- Stars: 1
- Watchers: 1
- Forks: 0
- Open Issues: 2
-
Metadata Files:
- Readme: readme.md
Awesome Lists containing this project
README
# open-radix-trie
Radix trie implementation with partial lookups and extensible paths.
## Usage
```typescript
import { OpenRadixTrie } from 'open-radix-trie'
```## API
### OpenRadixTrie
```typescript
class OpenRadixTrie<
TValue,
TContext extends Record = any
>
```A [radix trie](https://en.wikipedia.org/wiki/Radix_tree) that matches the largest prefix of a string that matches its nodes.
[xerpath](https://www.npmjs.com/package/xerpath) is used for routing.
#### set
```typescript
(path: ExtensiblePath | 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
```typescript
(path: string): { value: TValue | undefined; args: any[]; remainingPath: string }
```Gets the value of the data structure at the specified path.
Parameters:
* path#### buildPath
```typescript
(path: ExtensiblePath | string): (string | ExtensiblePathComponent)[]
```#### delete
```typescript
(path: ExtensiblePath | string): boolean
```#### entries, Symbol.iterator
```typescript
(): IterableIterator<[(string | ExtensiblePathComponent)[], TValue]>
```#### keys
```typescript
(): IterableIterator<(string | ExtensiblePathComponent)[]>
```#### values
```typescript
(): IterableIterator
```#### clear
```typescript
(): void
```#### forEach
```typescript
(callbackFn: (value: TValue, key: (string | ExtensiblePathComponent)[], trie: this) => void, thisArg?: any)
```#### has
```typescript
(path: string): boolean
```