vivth 1.5.3 → 1.5.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.
package/README.md CHANGED
@@ -3924,9 +3924,9 @@ f.forInSignals((key, signal) => {
3924
3924
 
3925
3925
  #### reference: `WalkThrough`
3926
3926
 
3927
- - collection of static `methods` to walktrhough things, instead of regular looping;
3928
- - usefull to iterator that might be modified during iteration;
3929
- - mostlikely to be less performant, but with better result clarity;
3927
+ - collection of static `methods` to walkthrough things, instead of regular looping;
3928
+ - useful for iterators that might be modified during iteration;
3929
+ - most likely to be less performant, but with better result clarity;
3930
3930
 
3931
3931
  #### reference: `WalkThrough.set`
3932
3932
 
@@ -3936,7 +3936,7 @@ f.forInSignals((key, signal) => {
3936
3936
  /**
3937
3937
  * @template VAL
3938
3938
  * @param {Set<VAL>} setInstance
3939
- * @param {(value:VAL)=>void} callback
3939
+ * @param {(value: VAL) => void} callback
3940
3940
  * @returns {void}
3941
3941
  */
3942
3942
  ```
@@ -3958,7 +3958,7 @@ WalkThrough.set(setOfSomething, (value) => {
3958
3958
  /**
3959
3959
  * @template KEY, VAL
3960
3960
  * @param {Map<KEY, VAL>} mapInstance
3961
- * @param {(res:[key: KEY, value: VAL]) => void} callback
3961
+ * @param {(entry: [key: KEY, value: VAL]) => void} callback
3962
3962
  * @returns {void}
3963
3963
  */
3964
3964
  ```
@@ -3980,7 +3980,7 @@ WalkThrough.map(mapOfSomething, ([key, value]) => {
3980
3980
  /**
3981
3981
  * @template VAL
3982
3982
  * @param {VAL[]} arrayInstance
3983
- * @param {(res:[value: VAL, index: number]) => void} callback
3983
+ * @param {(entry: [index: number, value: VAL]) => void} callback
3984
3984
  * @returns {void}
3985
3985
  */
3986
3986
  ```
@@ -3989,7 +3989,7 @@ WalkThrough.map(mapOfSomething, ([key, value]) => {
3989
3989
 
3990
3990
  ```js
3991
3991
  import { WalkThrough } from "vivth/neutral";
3992
- WalkThrough.array(arrayOfSomething, ([value, index]) => {
3992
+ WalkThrough.array(arrayOfSomething, ([index, value]) => {
3993
3993
  // code
3994
3994
  });
3995
3995
  ```
@@ -1,28 +1,29 @@
1
1
  /**
2
2
  * @description
3
- * - collection of static `methods` to walktrhough things, instead of regular looping;
4
- * - usefull to iterator that might be modified during iteration;
5
- * - mostlikely to be less performant, but with better result clarity;
3
+ * - collection of static `methods` to walkthrough things, instead of regular looping;
4
+ * - useful for iterators that might be modified during iteration;
5
+ * - most likely to be less performant, but with better result clarity;
6
6
  */
7
7
  export class WalkThrough {
8
8
  /**
9
- * @param {Iterator<any, any, any>} iterator
10
- * @param {(...any:any[])=>void} callback
9
+ * @template T
10
+ * @param {Iterator<T, any, any>} iterator
11
+ * @param {(value: T) => void} callback
11
12
  * @returns {void}
12
13
  */
13
- static #handler: (iterator: Iterator<any, any, any>, callback: (...any: any[]) => void) => void;
14
+ static #handler<T>(iterator: Iterator<T, any, any>, callback: (value: T) => void): void;
14
15
  /**
15
16
  * @description
16
17
  * - method helper to WalkThrough `Set`;
17
18
  * @template VAL
18
19
  * @param {Set<VAL>} setInstance
19
- * @param {(value:VAL)=>void} callback
20
+ * @param {(value: VAL) => void} callback
20
21
  * @returns {void}
21
22
  * @example
22
23
  * import { WalkThrough } from 'vivth/neutral';
23
24
  *
24
25
  * WalkThrough.set(setOfSomething, (value) => {
25
- * // code
26
+ * // code
26
27
  * })
27
28
  */
28
29
  static set<VAL>(setInstance: Set<VAL>, callback: (value: VAL) => void): void;
@@ -31,29 +32,29 @@ export class WalkThrough {
31
32
  * - method helper to WalkThrough `Map`;
32
33
  * @template KEY, VAL
33
34
  * @param {Map<KEY, VAL>} mapInstance
34
- * @param {(res:[key: KEY, value: VAL]) => void} callback
35
+ * @param {(entry: [key: KEY, value: VAL]) => void} callback
35
36
  * @returns {void}
36
37
  * @example
37
38
  * import { WalkThrough } from 'vivth/neutral';
38
39
  *
39
40
  * WalkThrough.map(mapOfSomething, ([key, value]) => {
40
- * // code
41
+ * // code
41
42
  * })
42
43
  */
43
- static map<KEY, VAL>(mapInstance: Map<KEY, VAL>, callback: (res: [key: KEY, value: VAL]) => void): void;
44
+ static map<KEY, VAL>(mapInstance: Map<KEY, VAL>, callback: (entry: [key: KEY, value: VAL]) => void): void;
44
45
  /**
45
46
  * @description
46
47
  * - method helper to WalkThrough `Array`;
47
48
  * @template VAL
48
49
  * @param {VAL[]} arrayInstance
49
- * @param {(res:[value: VAL, index: number]) => void} callback
50
+ * @param {(entry: [index: number, value: VAL]) => void} callback
50
51
  * @returns {void}
51
52
  * @example
52
53
  * import { WalkThrough } from 'vivth/neutral';
53
54
  *
54
- * WalkThrough.array(arrayOfSomething, ([value, index]) => {
55
- * // code
55
+ * WalkThrough.array(arrayOfSomething, ([index, value]) => {
56
+ * // code
56
57
  * })
57
58
  */
58
- static array<VAL>(arrayInstance: VAL[], callback: (res: [value: VAL, index: number]) => void): void;
59
+ static array<VAL>(arrayInstance: VAL[], callback: (entry: [index: number, value: VAL]) => void): void;
59
60
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "vivth",
3
- "version": "1.5.3",
3
+ "version": "1.5.4",
4
4
  "description": "library primitives",
5
5
  "devDependencies": {
6
6
  "@types/bun": "^1.3.3",
@@ -2,72 +2,77 @@
2
2
 
3
3
  /**
4
4
  * @description
5
- * - collection of static `methods` to walktrhough things, instead of regular looping;
6
- * - usefull to iterator that might be modified during iteration;
7
- * - mostlikely to be less performant, but with better result clarity;
5
+ * - collection of static `methods` to walkthrough things, instead of regular looping;
6
+ * - useful for iterators that might be modified during iteration;
7
+ * - most likely to be less performant, but with better result clarity;
8
8
  */
9
9
  export class WalkThrough {
10
10
  /**
11
- * @param {Iterator<any, any, any>} iterator
12
- * @param {(...any:any[])=>void} callback
11
+ * @template T
12
+ * @param {Iterator<T, any, any>} iterator
13
+ * @param {(value: T) => void} callback
13
14
  * @returns {void}
14
15
  */
15
- static #handler = (iterator, callback) => {
16
+ static #handler(iterator, callback) {
16
17
  let result = iterator.next();
17
18
  while (!result.done) {
18
19
  callback(result.value);
19
20
  result = iterator.next();
20
21
  }
21
- };
22
+ }
23
+
22
24
  /**
23
25
  * @description
24
26
  * - method helper to WalkThrough `Set`;
25
27
  * @template VAL
26
28
  * @param {Set<VAL>} setInstance
27
- * @param {(value:VAL)=>void} callback
29
+ * @param {(value: VAL) => void} callback
28
30
  * @returns {void}
29
31
  * @example
30
32
  * import { WalkThrough } from 'vivth/neutral';
31
33
  *
32
34
  * WalkThrough.set(setOfSomething, (value) => {
33
- * // code
35
+ * // code
34
36
  * })
35
37
  */
36
38
  static set(setInstance, callback) {
37
39
  WalkThrough.#handler(setInstance.values(), callback);
38
40
  }
41
+
39
42
  /**
40
43
  * @description
41
44
  * - method helper to WalkThrough `Map`;
42
45
  * @template KEY, VAL
43
46
  * @param {Map<KEY, VAL>} mapInstance
44
- * @param {(res:[key: KEY, value: VAL]) => void} callback
47
+ * @param {(entry: [key: KEY, value: VAL]) => void} callback
45
48
  * @returns {void}
46
49
  * @example
47
50
  * import { WalkThrough } from 'vivth/neutral';
48
51
  *
49
52
  * WalkThrough.map(mapOfSomething, ([key, value]) => {
50
- * // code
53
+ * // code
51
54
  * })
52
55
  */
53
56
  static map(mapInstance, callback) {
54
57
  WalkThrough.#handler(mapInstance.entries(), callback);
55
58
  }
59
+
56
60
  /**
57
61
  * @description
58
62
  * - method helper to WalkThrough `Array`;
59
63
  * @template VAL
60
64
  * @param {VAL[]} arrayInstance
61
- * @param {(res:[value: VAL, index: number]) => void} callback
65
+ * @param {(entry: [index: number, value: VAL]) => void} callback
62
66
  * @returns {void}
63
67
  * @example
64
68
  * import { WalkThrough } from 'vivth/neutral';
65
69
  *
66
- * WalkThrough.array(arrayOfSomething, ([value, index]) => {
67
- * // code
70
+ * WalkThrough.array(arrayOfSomething, ([index, value]) => {
71
+ * // code
68
72
  * })
69
73
  */
70
74
  static array(arrayInstance, callback) {
71
- WalkThrough.#handler(arrayInstance.values(), callback);
75
+ // Changed .values() to .entries() to match your [index, value] requirement
76
+ WalkThrough.#handler(arrayInstance.entries(), callback);
72
77
  }
73
78
  }