directed-graph-typed 1.47.1 → 1.47.2

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.
@@ -135,8 +135,35 @@ export declare class HashMap<K = any, V = any> {
135
135
  * HashMap. It takes three arguments:
136
136
  */
137
137
  forEach(callback: (element: [K, V], index: number, hashMap: HashMap<K, V>) => void): void;
138
+ /**
139
+ * The `filter` function takes a predicate function and returns a new HashMap containing only the
140
+ * key-value pairs that satisfy the predicate.
141
+ * @param predicate - The `predicate` parameter is a function that takes two arguments: `element` and
142
+ * `map`.
143
+ * @returns a new HashMap object that contains the key-value pairs from the original HashMap that
144
+ * satisfy the given predicate function.
145
+ */
138
146
  filter(predicate: (element: [K, V], map: HashMap<K, V>) => boolean): HashMap<K, V>;
147
+ /**
148
+ * The `map` function takes a callback function and returns a new HashMap with the values transformed
149
+ * by the callback.
150
+ * @param callback - The `callback` parameter is a function that takes two arguments: `element` and
151
+ * `map`.
152
+ * @returns a new HashMap object with the values mapped according to the provided callback function.
153
+ */
139
154
  map<NV>(callback: (element: [K, V], map: HashMap<K, V>) => NV): HashMap<K, NV>;
155
+ /**
156
+ * The `reduce` function iterates over the elements of a HashMap and applies a callback function to
157
+ * each element, accumulating a single value.
158
+ * @param callback - The callback parameter is a function that takes three arguments: accumulator,
159
+ * element, and map. It is called for each element in the HashMap and is used to accumulate a single
160
+ * result.
161
+ * @param {A} initialValue - The `initialValue` parameter is the initial value of the accumulator. It
162
+ * is the value that will be passed as the first argument to the `callback` function when reducing
163
+ * the elements of the map.
164
+ * @returns The `reduce` function is returning the final value of the accumulator after iterating
165
+ * over all the elements in the HashMap and applying the callback function to each element.
166
+ */
140
167
  reduce<A>(callback: (accumulator: A, element: [K, V], map: HashMap<K, V>) => A, initialValue: A): A;
141
168
  /**
142
169
  * Time Complexity: O(n), where n is the number of elements in the HashMap.
@@ -277,6 +277,14 @@ class HashMap {
277
277
  node = node.next;
278
278
  }
279
279
  }
280
+ /**
281
+ * The `filter` function takes a predicate function and returns a new HashMap containing only the
282
+ * key-value pairs that satisfy the predicate.
283
+ * @param predicate - The `predicate` parameter is a function that takes two arguments: `element` and
284
+ * `map`.
285
+ * @returns a new HashMap object that contains the key-value pairs from the original HashMap that
286
+ * satisfy the given predicate function.
287
+ */
280
288
  filter(predicate) {
281
289
  const filteredMap = new HashMap();
282
290
  for (const [key, value] of this) {
@@ -286,6 +294,13 @@ class HashMap {
286
294
  }
287
295
  return filteredMap;
288
296
  }
297
+ /**
298
+ * The `map` function takes a callback function and returns a new HashMap with the values transformed
299
+ * by the callback.
300
+ * @param callback - The `callback` parameter is a function that takes two arguments: `element` and
301
+ * `map`.
302
+ * @returns a new HashMap object with the values mapped according to the provided callback function.
303
+ */
289
304
  map(callback) {
290
305
  const mappedMap = new HashMap();
291
306
  for (const [key, value] of this) {
@@ -294,6 +309,18 @@ class HashMap {
294
309
  }
295
310
  return mappedMap;
296
311
  }
312
+ /**
313
+ * The `reduce` function iterates over the elements of a HashMap and applies a callback function to
314
+ * each element, accumulating a single value.
315
+ * @param callback - The callback parameter is a function that takes three arguments: accumulator,
316
+ * element, and map. It is called for each element in the HashMap and is used to accumulate a single
317
+ * result.
318
+ * @param {A} initialValue - The `initialValue` parameter is the initial value of the accumulator. It
319
+ * is the value that will be passed as the first argument to the `callback` function when reducing
320
+ * the elements of the map.
321
+ * @returns The `reduce` function is returning the final value of the accumulator after iterating
322
+ * over all the elements in the HashMap and applying the callback function to each element.
323
+ */
297
324
  reduce(callback, initialValue) {
298
325
  let accumulator = initialValue;
299
326
  for (const element of this) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "directed-graph-typed",
3
- "version": "1.47.1",
3
+ "version": "1.47.2",
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.47.1"
150
+ "data-structure-typed": "^1.47.2"
151
151
  }
152
152
  }
@@ -305,6 +305,14 @@ export class HashMap<K = any, V = any> {
305
305
  }
306
306
  }
307
307
 
308
+ /**
309
+ * The `filter` function takes a predicate function and returns a new HashMap containing only the
310
+ * key-value pairs that satisfy the predicate.
311
+ * @param predicate - The `predicate` parameter is a function that takes two arguments: `element` and
312
+ * `map`.
313
+ * @returns a new HashMap object that contains the key-value pairs from the original HashMap that
314
+ * satisfy the given predicate function.
315
+ */
308
316
  filter(predicate: (element: [K, V], map: HashMap<K, V>) => boolean): HashMap<K, V> {
309
317
  const filteredMap = new HashMap<K, V>();
310
318
  for (const [key, value] of this) {
@@ -315,6 +323,13 @@ export class HashMap<K = any, V = any> {
315
323
  return filteredMap;
316
324
  }
317
325
 
326
+ /**
327
+ * The `map` function takes a callback function and returns a new HashMap with the values transformed
328
+ * by the callback.
329
+ * @param callback - The `callback` parameter is a function that takes two arguments: `element` and
330
+ * `map`.
331
+ * @returns a new HashMap object with the values mapped according to the provided callback function.
332
+ */
318
333
  map<NV>(callback: (element: [K, V], map: HashMap<K, V>) => NV): HashMap<K, NV> {
319
334
  const mappedMap = new HashMap<K, NV>();
320
335
  for (const [key, value] of this) {
@@ -324,6 +339,18 @@ export class HashMap<K = any, V = any> {
324
339
  return mappedMap;
325
340
  }
326
341
 
342
+ /**
343
+ * The `reduce` function iterates over the elements of a HashMap and applies a callback function to
344
+ * each element, accumulating a single value.
345
+ * @param callback - The callback parameter is a function that takes three arguments: accumulator,
346
+ * element, and map. It is called for each element in the HashMap and is used to accumulate a single
347
+ * result.
348
+ * @param {A} initialValue - The `initialValue` parameter is the initial value of the accumulator. It
349
+ * is the value that will be passed as the first argument to the `callback` function when reducing
350
+ * the elements of the map.
351
+ * @returns The `reduce` function is returning the final value of the accumulator after iterating
352
+ * over all the elements in the HashMap and applying the callback function to each element.
353
+ */
327
354
  reduce<A>(callback: (accumulator: A, element: [K, V], map: HashMap<K, V>) => A, initialValue: A): A {
328
355
  let accumulator = initialValue;
329
356
  for (const element of this) {