directed-graph-typed 1.52.2 → 1.52.3

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.
@@ -418,8 +418,13 @@ class Trie extends base_1.IterableElementBase {
418
418
  if (prefix) {
419
419
  for (const c of prefix) {
420
420
  const nodeC = startNode.children.get(c);
421
- if (nodeC)
421
+ if (nodeC) {
422
422
  startNode = nodeC;
423
+ }
424
+ else {
425
+ // Early return if the whole prefix is not found
426
+ return [];
427
+ }
423
428
  }
424
429
  }
425
430
  if (isAllWhenEmptyPrefix || startNode !== this.root)
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "directed-graph-typed",
3
- "version": "1.52.2",
3
+ "version": "1.52.3",
4
4
  "description": "Directed Graph. Javascript & Typescript Data Structure.",
5
5
  "main": "dist/index.js",
6
6
  "scripts": {
@@ -147,6 +147,6 @@
147
147
  "typescript": "^4.9.5"
148
148
  },
149
149
  "dependencies": {
150
- "data-structure-typed": "^1.52.2"
150
+ "data-structure-typed": "^1.52.3"
151
151
  }
152
152
  }
@@ -454,7 +454,12 @@ export class Trie<R = any> extends IterableElementBase<string, R, Trie<R>> {
454
454
  if (prefix) {
455
455
  for (const c of prefix) {
456
456
  const nodeC = startNode.children.get(c);
457
- if (nodeC) startNode = nodeC;
457
+ if (nodeC) {
458
+ startNode = nodeC;
459
+ } else {
460
+ // Early return if the whole prefix is not found
461
+ return [];
462
+ }
458
463
  }
459
464
  }
460
465