@mangos/radix 0.0.9 → 1.0.4

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -12,4 +12,5 @@ export declare class RadixNodeImpl<T extends Token> implements RadixNode<T> {
12
12
  id(): T;
13
13
  nrTerminals(): number;
14
14
  delete(path: readonly T[]): number;
15
+ terminals(): RadixNode<T>[];
15
16
  }
@@ -112,6 +112,13 @@ class RadixNodeImpl {
112
112
  this.#parent = this;
113
113
  return nrNodesChanged + 1;
114
114
  }
115
+ terminals() {
116
+ if (this.#children.length === 0) {
117
+ return [this];
118
+ }
119
+ const allTerminals = this.#children.flatMap((child) => child.terminals());
120
+ return allTerminals;
121
+ }
115
122
  }
116
123
  export {
117
124
  RadixNodeImpl
@@ -1,5 +1,6 @@
1
1
  import type { Token } from './Token';
2
2
  export interface RadixNode<T extends Token> {
3
+ terminals(): RadixNode<T>[];
3
4
  nrTerminals(): number;
4
5
  select(path: readonly T[]): null | RadixNode<T>;
5
6
  delete(this: RadixNode<T>, path: readonly T[]): number;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@mangos/radix",
3
- "version": "0.0.9",
3
+ "version": "1.0.4",
4
4
  "author": "jacob bogers <jkfbogers@gmail.com>",
5
5
  "repository": {
6
6
  "type": "git",