undirected-graph-typed 1.52.2 → 1.52.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.
@@ -26,12 +26,10 @@ class HashMap extends base_1.IterableEntryBase {
26
26
  this._hashFn = (key) => String(key);
27
27
  if (options) {
28
28
  const { hashFn, toEntryFn } = options;
29
- if (hashFn) {
29
+ if (hashFn)
30
30
  this._hashFn = hashFn;
31
- }
32
- if (toEntryFn) {
31
+ if (toEntryFn)
33
32
  this._toEntryFn = toEntryFn;
34
- }
35
33
  }
36
34
  if (entryOrRawElements) {
37
35
  this.setMany(entryOrRawElements);
@@ -95,9 +95,9 @@ export declare class Queue<E = any, R = any> extends IterableElementBase<E, R, Q
95
95
  * Time Complexity: O(1)
96
96
  * Space Complexity: O(1)
97
97
  *
98
- * The push function adds an element to the end of the queue and returns the updated queue.Adds an element at the back of the queue.
98
+ * The push function adds an element to the end of the queue and returns true. Adds an element at the back of the queue.
99
99
  * @param {E} element - The `element` parameter represents the element that you want to add to the queue.
100
- * @returns The `add` method is returning a `Queue<E>` object.
100
+ * @returns Always returns true, indicating the element was successfully added.
101
101
  */
102
102
  push(element: E): boolean;
103
103
  /**
@@ -115,13 +115,13 @@ export declare class Queue<E = any, R = any> extends IterableElementBase<E, R, Q
115
115
  shift(): E | undefined;
116
116
  /**
117
117
  * The delete function removes an element from the list.
118
- * @param element: E Specify the element to be deleted
118
+ * @param {E} element - Specify the element to be deleted
119
119
  * @return A boolean value indicating whether the element was successfully deleted or not
120
120
  */
121
121
  delete(element: E): boolean;
122
122
  /**
123
123
  * The deleteAt function deletes the element at a given index.
124
- * @param index: number Determine the index of the element to be deleted
124
+ * @param {number} index - Determine the index of the element to be deleted
125
125
  * @return A boolean value
126
126
  */
127
127
  deleteAt(index: number): boolean;
@@ -122,9 +122,9 @@ class Queue extends base_1.IterableElementBase {
122
122
  * Time Complexity: O(1)
123
123
  * Space Complexity: O(1)
124
124
  *
125
- * The push function adds an element to the end of the queue and returns the updated queue.Adds an element at the back of the queue.
125
+ * The push function adds an element to the end of the queue and returns true. Adds an element at the back of the queue.
126
126
  * @param {E} element - The `element` parameter represents the element that you want to add to the queue.
127
- * @returns The `add` method is returning a `Queue<E>` object.
127
+ * @returns Always returns true, indicating the element was successfully added.
128
128
  */
129
129
  push(element) {
130
130
  this.elements.push(element);
@@ -153,7 +153,7 @@ class Queue extends base_1.IterableElementBase {
153
153
  }
154
154
  /**
155
155
  * The delete function removes an element from the list.
156
- * @param element: E Specify the element to be deleted
156
+ * @param {E} element - Specify the element to be deleted
157
157
  * @return A boolean value indicating whether the element was successfully deleted or not
158
158
  */
159
159
  delete(element) {
@@ -162,7 +162,7 @@ class Queue extends base_1.IterableElementBase {
162
162
  }
163
163
  /**
164
164
  * The deleteAt function deletes the element at a given index.
165
- * @param index: number Determine the index of the element to be deleted
165
+ * @param {number} index - Determine the index of the element to be deleted
166
166
  * @return A boolean value
167
167
  */
168
168
  deleteAt(index) {
@@ -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": "undirected-graph-typed",
3
- "version": "1.52.2",
3
+ "version": "1.52.4",
4
4
  "description": "Undirected Graph. Javascript & Typescript Data Structure.",
5
5
  "main": "dist/index.js",
6
6
  "scripts": {
@@ -145,6 +145,6 @@
145
145
  "typescript": "^4.9.5"
146
146
  },
147
147
  "dependencies": {
148
- "data-structure-typed": "^1.52.2"
148
+ "data-structure-typed": "^1.52.4"
149
149
  }
150
150
  }
@@ -34,12 +34,8 @@ export class HashMap<K = any, V = any, R = [K, V]> extends IterableEntryBase<K,
34
34
  super();
35
35
  if (options) {
36
36
  const { hashFn, toEntryFn } = options;
37
- if (hashFn) {
38
- this._hashFn = hashFn;
39
- }
40
- if (toEntryFn) {
41
- this._toEntryFn = toEntryFn;
42
- }
37
+ if (hashFn) this._hashFn = hashFn;
38
+ if (toEntryFn) this._toEntryFn = toEntryFn;
43
39
  }
44
40
  if (entryOrRawElements) {
45
41
  this.setMany(entryOrRawElements);
@@ -142,9 +142,9 @@ export class Queue<E = any, R = any> extends IterableElementBase<E, R, Queue<E,
142
142
  * Time Complexity: O(1)
143
143
  * Space Complexity: O(1)
144
144
  *
145
- * The push function adds an element to the end of the queue and returns the updated queue.Adds an element at the back of the queue.
145
+ * The push function adds an element to the end of the queue and returns true. Adds an element at the back of the queue.
146
146
  * @param {E} element - The `element` parameter represents the element that you want to add to the queue.
147
- * @returns The `add` method is returning a `Queue<E>` object.
147
+ * @returns Always returns true, indicating the element was successfully added.
148
148
  */
149
149
  push(element: E): boolean {
150
150
  this.elements.push(element);
@@ -176,7 +176,7 @@ export class Queue<E = any, R = any> extends IterableElementBase<E, R, Queue<E,
176
176
 
177
177
  /**
178
178
  * The delete function removes an element from the list.
179
- * @param element: E Specify the element to be deleted
179
+ * @param {E} element - Specify the element to be deleted
180
180
  * @return A boolean value indicating whether the element was successfully deleted or not
181
181
  */
182
182
  delete(element: E): boolean {
@@ -186,7 +186,7 @@ export class Queue<E = any, R = any> extends IterableElementBase<E, R, Queue<E,
186
186
 
187
187
  /**
188
188
  * The deleteAt function deletes the element at a given index.
189
- * @param index: number Determine the index of the element to be deleted
189
+ * @param {number} index - Determine the index of the element to be deleted
190
190
  * @return A boolean value
191
191
  */
192
192
  deleteAt(index: number): boolean {
@@ -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