File tree 4 files changed +22
-5
lines changed 4 files changed +22
-5
lines changed Original file line number Diff line number Diff line change @@ -126,7 +126,9 @@ isEmpty: boolean
126
126
```tsx
127
127
size: number
128
128
```
129
- ## Methods
129
+
130
+ ## Methods (Scope: Public)
131
+
130
132
### add
131
133
<p >Accepts a sequence of items to merge into this instance.</p >
132
134
@@ -288,6 +290,15 @@ Accepts sequences of items to remove from the trie. Will record the outcome of t
288
290
removeMany(data : Array<Iterable <T >>): Array<OpStatus >
289
291
```
290
292
293
+ ## Methods (Scope: Protected)
294
+
295
+ ### _getNodeAtPrefixEnd
296
+ <p >Produces the underlying node containing the final value in <code >prefix</code > items.</p >
297
+ <p >Will produce the root node for the empty <code >prefix</code > items.</p >
298
+
299
+ ```tsx
300
+ _getNodeAtPrefixEnd( prefix: Iterable<T > ): Node<T >
301
+ ```
291
302
## Static
292
303
293
304
### makeTrieable
Original file line number Diff line number Diff line change 59
59
"test:watch" : " jest --updateSnapshot --watchAll"
60
60
},
61
61
"types" : " dist/index.d.ts" ,
62
- "version" : " 0.5.1 "
62
+ "version" : " 0.5.2 "
63
63
}
Original file line number Diff line number Diff line change 1
1
export type {
2
2
EqualityFn ,
3
3
KeyType ,
4
+ Node ,
4
5
Options ,
5
6
OpStatus ,
6
7
Status ,
7
8
TrieableNode ,
8
9
TrieableNodeKeyMapping
9
10
} from './main' ;
10
-
11
11
export { default as default } from './main' ;
Original file line number Diff line number Diff line change @@ -335,9 +335,15 @@ export default class Trie<T = unknown> {
335
335
}
336
336
return results ;
337
337
}
338
+ protected _getNodeAtPrefixEnd ( prefix : Iterable < T > ) {
339
+ const pSequence = toArray ( prefix ) ;
340
+ return pSequence . length
341
+ ? this . root . getChildPrefixEnd ( pSequence )
342
+ : this . root ;
343
+ }
338
344
private _getAllStartingWith ( prefix : Array < T > , completeSequencesOnly ) {
339
- const suffixStartNode = this . root . getChildPrefixEnd ( prefix ) ;
340
- if ( ! suffixStartNode ) { return [ ] }
345
+ const suffixStartNode = this . _getNodeAtPrefixEnd ( prefix ) ;
346
+ if ( ! suffixStartNode || this . root === suffixStartNode ) { return [ ] }
341
347
const sequences = suffixStartNode . asArray ( completeSequencesOnly ) ;
342
348
for ( let s = sequences . length ; s -- ; ) {
343
349
sequences [ s ] = prefix . concat ( sequences [ s ] ) ;
You can’t perform that action at this time.
0 commit comments