@kikiutils/shared 18.0.1 → 18.2.0

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.
Files changed (156) hide show
  1. package/dist/buffer.d.ts +19 -21
  2. package/dist/buffer.d.ts.map +1 -1
  3. package/dist/buffer.js +18 -19
  4. package/dist/buffer.js.map +1 -1
  5. package/dist/classes/enhanced-date.d.ts +457 -0
  6. package/dist/classes/enhanced-date.d.ts.map +1 -0
  7. package/dist/classes/enhanced-date.js +635 -0
  8. package/dist/classes/enhanced-date.js.map +1 -0
  9. package/dist/classes/path.d.ts +211 -48
  10. package/dist/classes/path.d.ts.map +1 -1
  11. package/dist/classes/path.js +188 -54
  12. package/dist/classes/path.js.map +1 -1
  13. package/dist/classes/precision-number.d.ts +44 -39
  14. package/dist/classes/precision-number.d.ts.map +1 -1
  15. package/dist/classes/precision-number.js +51 -45
  16. package/dist/classes/precision-number.js.map +1 -1
  17. package/dist/classes/ssh-client.d.ts +3 -4
  18. package/dist/classes/ssh-client.d.ts.map +1 -1
  19. package/dist/classes/ssh-client.js +2 -2
  20. package/dist/classes/ssh-client.js.map +1 -1
  21. package/dist/clipboard.d.ts +25 -26
  22. package/dist/clipboard.d.ts.map +1 -1
  23. package/dist/clipboard.js +23 -23
  24. package/dist/clipboard.js.map +1 -1
  25. package/dist/consola.d.ts +12 -15
  26. package/dist/consola.d.ts.map +1 -1
  27. package/dist/consola.js +10 -12
  28. package/dist/consola.js.map +1 -1
  29. package/dist/crypto-hash.d.ts +65 -56
  30. package/dist/crypto-hash.d.ts.map +1 -1
  31. package/dist/crypto-hash.js +55 -45
  32. package/dist/crypto-hash.js.map +1 -1
  33. package/dist/datetime.d.ts +41 -53
  34. package/dist/datetime.d.ts.map +1 -1
  35. package/dist/datetime.js +53 -66
  36. package/dist/datetime.js.map +1 -1
  37. package/dist/element-plus.d.ts +13 -14
  38. package/dist/element-plus.d.ts.map +1 -1
  39. package/dist/element-plus.js +11 -11
  40. package/dist/element-plus.js.map +1 -1
  41. package/dist/enum.d.ts +39 -36
  42. package/dist/enum.d.ts.map +1 -1
  43. package/dist/enum.js +36 -32
  44. package/dist/enum.js.map +1 -1
  45. package/dist/env.d.ts +22 -15
  46. package/dist/env.d.ts.map +1 -1
  47. package/dist/env.js +20 -12
  48. package/dist/env.js.map +1 -1
  49. package/dist/event-awaiter.d.ts +47 -52
  50. package/dist/event-awaiter.d.ts.map +1 -1
  51. package/dist/event-awaiter.js +46 -50
  52. package/dist/event-awaiter.js.map +1 -1
  53. package/dist/general.d.ts +22 -17
  54. package/dist/general.d.ts.map +1 -1
  55. package/dist/general.js.map +1 -1
  56. package/dist/hash.d.ts +24 -21
  57. package/dist/hash.d.ts.map +1 -1
  58. package/dist/hash.js +20 -16
  59. package/dist/hash.js.map +1 -1
  60. package/dist/math.d.ts +20 -19
  61. package/dist/math.d.ts.map +1 -1
  62. package/dist/math.js +14 -12
  63. package/dist/math.js.map +1 -1
  64. package/dist/number.d.ts +10 -9
  65. package/dist/number.d.ts.map +1 -1
  66. package/dist/number.js +9 -7
  67. package/dist/number.js.map +1 -1
  68. package/dist/object.d.ts +22 -10
  69. package/dist/object.d.ts.map +1 -1
  70. package/dist/object.js +21 -8
  71. package/dist/object.js.map +1 -1
  72. package/dist/pino.d.ts +13 -15
  73. package/dist/pino.d.ts.map +1 -1
  74. package/dist/pino.js +10 -15
  75. package/dist/pino.js.map +1 -1
  76. package/dist/random.d.ts +17 -15
  77. package/dist/random.d.ts.map +1 -1
  78. package/dist/random.js +16 -13
  79. package/dist/random.js.map +1 -1
  80. package/dist/redis/script-runner.d.ts +57 -0
  81. package/dist/redis/script-runner.d.ts.map +1 -0
  82. package/dist/redis/script-runner.js +46 -0
  83. package/dist/redis/script-runner.js.map +1 -0
  84. package/dist/storages/lru/keyed-store.d.ts +18 -14
  85. package/dist/storages/lru/keyed-store.d.ts.map +1 -1
  86. package/dist/storages/lru/keyed-store.js +17 -12
  87. package/dist/storages/lru/keyed-store.js.map +1 -1
  88. package/dist/storages/redis/keyed-store.d.ts +11 -21
  89. package/dist/storages/redis/keyed-store.d.ts.map +1 -1
  90. package/dist/storages/redis/keyed-store.js +10 -19
  91. package/dist/storages/redis/keyed-store.js.map +1 -1
  92. package/dist/storages/redis/msgpack.d.ts +33 -13
  93. package/dist/storages/redis/msgpack.d.ts.map +1 -1
  94. package/dist/storages/redis/msgpack.js +32 -11
  95. package/dist/storages/redis/msgpack.js.map +1 -1
  96. package/dist/storages/redis/types.d.ts +34 -17
  97. package/dist/storages/redis/types.d.ts.map +1 -1
  98. package/dist/string.d.ts +12 -11
  99. package/dist/string.d.ts.map +1 -1
  100. package/dist/string.js +20 -15
  101. package/dist/string.js.map +1 -1
  102. package/dist/time.d.ts +26 -21
  103. package/dist/time.d.ts.map +1 -1
  104. package/dist/time.js +24 -18
  105. package/dist/time.js.map +1 -1
  106. package/dist/types/filtered-key-path.d.ts +4 -15
  107. package/dist/types/filtered-key-path.d.ts.map +1 -1
  108. package/dist/types/index.d.ts +10 -10
  109. package/dist/types/index.d.ts.map +1 -1
  110. package/dist/types/vue.d.ts +7 -7
  111. package/dist/types/vue.d.ts.map +1 -1
  112. package/dist/url.d.ts +15 -14
  113. package/dist/url.d.ts.map +1 -1
  114. package/dist/url.js +12 -10
  115. package/dist/url.js.map +1 -1
  116. package/dist/vue.d.ts +19 -21
  117. package/dist/vue.d.ts.map +1 -1
  118. package/dist/vue.js +15 -16
  119. package/dist/vue.js.map +1 -1
  120. package/dist/web.d.ts +14 -11
  121. package/dist/web.d.ts.map +1 -1
  122. package/dist/web.js +12 -8
  123. package/dist/web.js.map +1 -1
  124. package/package.json +21 -21
  125. package/src/buffer.ts +18 -19
  126. package/src/classes/enhanced-date.ts +715 -0
  127. package/src/classes/path.ts +248 -96
  128. package/src/classes/precision-number.ts +61 -53
  129. package/src/classes/ssh-client.ts +8 -5
  130. package/src/clipboard.ts +23 -23
  131. package/src/consola.ts +10 -12
  132. package/src/crypto-hash.ts +55 -45
  133. package/src/datetime.ts +65 -85
  134. package/src/element-plus.ts +11 -11
  135. package/src/enum.ts +36 -32
  136. package/src/env.ts +20 -12
  137. package/src/event-awaiter.ts +49 -50
  138. package/src/general.ts +20 -14
  139. package/src/hash.ts +20 -16
  140. package/src/math.ts +18 -16
  141. package/src/number.ts +9 -7
  142. package/src/object.ts +21 -8
  143. package/src/pino.ts +11 -15
  144. package/src/random.ts +16 -13
  145. package/src/redis/script-runner.ts +107 -0
  146. package/src/storages/lru/keyed-store.ts +17 -12
  147. package/src/storages/redis/keyed-store.ts +10 -19
  148. package/src/storages/redis/msgpack.ts +32 -11
  149. package/src/storages/redis/types.ts +32 -14
  150. package/src/string.ts +10 -8
  151. package/src/time.ts +24 -18
  152. package/src/types/filtered-key-path.ts +9 -14
  153. package/src/types/vue.ts +6 -5
  154. package/src/url.ts +12 -10
  155. package/src/vue.ts +15 -16
  156. package/src/web.ts +12 -8
package/dist/enum.js CHANGED
@@ -2,24 +2,25 @@
2
2
  /**
3
3
  * Extracts only the numeric values from an enumeration-like object.
4
4
  *
5
- * @template T - The type of the enum object
5
+ * @typeParam T - The type of the enum object.
6
6
  *
7
- * @param {T} enumObject - The enumeration-like object to extract numeric values from,
7
+ * @param enumObject - The enumeration-like object to extract numeric values from,
8
8
  * the object can contain numeric values, string values, or both.
9
9
  *
10
- * @returns {Extract<T[keyof T], number>[]} An array of numeric values extracted from the enum object
10
+ * @returns An array of numeric values extracted from the enum object.
11
11
  *
12
12
  * @example
13
- * ```typescript
13
+ *
14
+ * ```ts
14
15
  * import { getEnumNumberValues } from '@kikiutils/shared/enum';
15
16
  *
16
17
  * enum RecordType {
17
- * Receive = 0,
18
- * Send = 1,
19
- * Unknown = 'unknown'
18
+ * Receive = 0,
19
+ * Send = 1,
20
+ * Unknown = 'unknown',
20
21
  * }
21
22
  *
22
- * console.log(getEnumNumberValues(RecordType)); // [0, 1]
23
+ * console.log(getEnumNumberValues(RecordType)); // => [0, 1]
23
24
  * ```
24
25
  */
25
26
  function getEnumNumberValues(enumObject) {
@@ -28,24 +29,25 @@ function getEnumNumberValues(enumObject) {
28
29
  /**
29
30
  * Extracts only the string values from an enumeration-like object.
30
31
  *
31
- * @template T - The type of the enum object
32
+ * @typeParam T - The type of the enum object.
32
33
  *
33
- * @param {T} enumObject - The enumeration-like object to extract string values from,
34
+ * @param enumObject - The enumeration-like object to extract string values from,
34
35
  * the object can contain numeric values, string values, or both.
35
36
  *
36
- * @returns {Extract<T[keyof T], string>[]} An array of string values extracted from the enum object
37
+ * @returns An array of string values extracted from the enum object.
37
38
  *
38
39
  * @example
39
- * ```typescript
40
+ *
41
+ * ```ts
40
42
  * import { getEnumStringValues } from '@kikiutils/shared/enum';
41
43
  *
42
44
  * enum RecordType {
43
- * Receive = 0,
44
- * Send = 1,
45
- * Unknown = 'unknown'
45
+ * Receive = 0,
46
+ * Send = 1,
47
+ * Unknown = 'unknown',
46
48
  * }
47
49
  *
48
- * console.log(getEnumStringValues(RecordType)); // ['unknown']
50
+ * console.log(getEnumStringValues(RecordType)); // => ['unknown']
49
51
  * ```
50
52
  */
51
53
  function getEnumStringValues(enumObject) {
@@ -54,47 +56,49 @@ function getEnumStringValues(enumObject) {
54
56
  /**
55
57
  * Extracts all values from an enumeration-like object.
56
58
  *
59
+ * @remarks
57
60
  * This function handles TypeScript enums correctly by accounting for the reverse mapping
58
61
  * that occurs with numeric enums. It works with pure numeric enums, pure string enums,
59
62
  * and mixed enums.
60
63
  *
61
- * @template T - The type of the enum object
64
+ * @typeParam T - The type of the enum object.
62
65
  *
63
- * @param {T} enumObject - The enumeration-like object to extract values from,
66
+ * @param enumObject - The enumeration-like object to extract values from,
64
67
  * the object can contain numeric values, string values, or both.
65
68
  *
66
- * @returns {(T[keyof T])[]} An array containing all the values from the enum object
69
+ * @returns An array containing all the values from the enum object.
67
70
  *
68
71
  * @example
69
- * ```typescript
72
+ *
73
+ * ```ts
70
74
  * import { getEnumValues } from '@kikiutils/shared/enum';
71
75
  *
72
76
  * // Numeric enum
73
77
  * enum Status {
74
- * Active = 0,
75
- * Inactive = 1,
76
- * Pending = 2
78
+ * Active = 0,
79
+ * Inactive = 1,
80
+ * Pending = 2,
77
81
  * }
78
82
  *
79
- * console.log(getEnumValues(Status)); // [0, 1, 2]
83
+ * console.log(getEnumValues(Status)); // => [0, 1, 2]
80
84
  *
81
85
  * // String enum
82
86
  * enum Color {
83
- * Red = 'RED',
84
- * Green = 'GREEN',
85
- * Blue = 'BLUE'
87
+ * Red = 'RED',
88
+ * Green = 'GREEN',
89
+ * Blue = 'BLUE',
86
90
  * }
87
91
  *
88
- * console.log(getEnumValues(Color)); // ['RED', 'GREEN', 'BLUE']
92
+ * console.log(getEnumValues(Color)); // => ['RED', 'GREEN', 'BLUE']
89
93
  *
90
94
  * // Mixed enum
91
95
  * enum RecordType {
92
- * Receive = 0,
93
- * Send = 1,
94
- * Unknown = 'unknown'
96
+ * Receive = 0,
97
+ * Send = 1,
98
+ * Unknown = 'unknown',
95
99
  * }
96
100
  *
97
- * console.log(getEnumValues(RecordType)); // [0, 1, 'unknown']
101
+ * console.log(getEnumValues(RecordType)); // => [0, 1, 'unknown']
98
102
  * ```
99
103
  */
100
104
  function getEnumValues(enumObject) {
package/dist/enum.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"enum.js","names":[],"sources":["../src/enum.ts"],"sourcesContent":["/**\n * Extracts only the numeric values from an enumeration-like object.\n *\n * @template T - The type of the enum object\n *\n * @param {T} enumObject - The enumeration-like object to extract numeric values from,\n * the object can contain numeric values, string values, or both.\n *\n * @returns {Extract<T[keyof T], number>[]} An array of numeric values extracted from the enum object\n *\n * @example\n * ```typescript\n * import { getEnumNumberValues } from '@kikiutils/shared/enum';\n *\n * enum RecordType {\n * Receive = 0,\n * Send = 1,\n * Unknown = 'unknown'\n * }\n *\n * console.log(getEnumNumberValues(RecordType)); // [0, 1]\n * ```\n */\nexport function getEnumNumberValues<T extends Record<string, any>>(enumObject: T): Extract<T[keyof T], number>[] {\n return getEnumValues(enumObject).filter((value) => typeof value === 'number');\n}\n\n/**\n * Extracts only the string values from an enumeration-like object.\n *\n * @template T - The type of the enum object\n *\n * @param {T} enumObject - The enumeration-like object to extract string values from,\n * the object can contain numeric values, string values, or both.\n *\n * @returns {Extract<T[keyof T], string>[]} An array of string values extracted from the enum object\n *\n * @example\n * ```typescript\n * import { getEnumStringValues } from '@kikiutils/shared/enum';\n *\n * enum RecordType {\n * Receive = 0,\n * Send = 1,\n * Unknown = 'unknown'\n * }\n *\n * console.log(getEnumStringValues(RecordType)); // ['unknown']\n * ```\n */\nexport function getEnumStringValues<T extends Record<string, any>>(enumObject: T): Extract<T[keyof T], string>[] {\n return getEnumValues(enumObject).filter((value) => typeof value === 'string');\n}\n\n/**\n * Extracts all values from an enumeration-like object.\n *\n * This function handles TypeScript enums correctly by accounting for the reverse mapping\n * that occurs with numeric enums. It works with pure numeric enums, pure string enums,\n * and mixed enums.\n *\n * @template T - The type of the enum object\n *\n * @param {T} enumObject - The enumeration-like object to extract values from,\n * the object can contain numeric values, string values, or both.\n *\n * @returns {(T[keyof T])[]} An array containing all the values from the enum object\n *\n * @example\n * ```typescript\n * import { getEnumValues } from '@kikiutils/shared/enum';\n *\n * // Numeric enum\n * enum Status {\n * Active = 0,\n * Inactive = 1,\n * Pending = 2\n * }\n *\n * console.log(getEnumValues(Status)); // [0, 1, 2]\n *\n * // String enum\n * enum Color {\n * Red = 'RED',\n * Green = 'GREEN',\n * Blue = 'BLUE'\n * }\n *\n * console.log(getEnumValues(Color)); // ['RED', 'GREEN', 'BLUE']\n *\n * // Mixed enum\n * enum RecordType {\n * Receive = 0,\n * Send = 1,\n * Unknown = 'unknown'\n * }\n *\n * console.log(getEnumValues(RecordType)); // [0, 1, 'unknown']\n * ```\n */\nexport function getEnumValues<T extends Record<string, any>>(enumObject: T): (T[keyof T])[] {\n const values = Object.values(enumObject);\n const hasNumberValues = values.some((value) => typeof value === 'number');\n if (!hasNumberValues) return values;\n return Object.keys(enumObject).filter((key) => Number.isNaN(Number(key))).map((key) => enumObject[key]);\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;AAuBA,SAAgB,oBAAmD,YAA8C;CAC7G,OAAO,cAAc,UAAU,CAAC,CAAC,QAAQ,UAAU,OAAO,UAAU,QAAQ;AAChF;;;;;;;;;;;;;;;;;;;;;;;;AAyBA,SAAgB,oBAAmD,YAA8C;CAC7G,OAAO,cAAc,UAAU,CAAC,CAAC,QAAQ,UAAU,OAAO,UAAU,QAAQ;AAChF;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAgDA,SAAgB,cAA6C,YAA+B;CACxF,MAAM,SAAS,OAAO,OAAO,UAAU;CAEvC,IAAI,CADoB,OAAO,MAAM,UAAU,OAAO,UAAU,QAC7C,GAAG,OAAO;CAC7B,OAAO,OAAO,KAAK,UAAU,CAAC,CAAC,QAAQ,QAAQ,OAAO,MAAM,OAAO,GAAG,CAAC,CAAC,CAAC,CAAC,KAAK,QAAQ,WAAW,IAAI;AAC1G"}
1
+ {"version":3,"file":"enum.js","names":[],"sources":["../src/enum.ts"],"sourcesContent":["/**\n * Extracts only the numeric values from an enumeration-like object.\n *\n * @typeParam T - The type of the enum object.\n *\n * @param enumObject - The enumeration-like object to extract numeric values from,\n * the object can contain numeric values, string values, or both.\n *\n * @returns An array of numeric values extracted from the enum object.\n *\n * @example\n *\n * ```ts\n * import { getEnumNumberValues } from '@kikiutils/shared/enum';\n *\n * enum RecordType {\n * Receive = 0,\n * Send = 1,\n * Unknown = 'unknown',\n * }\n *\n * console.log(getEnumNumberValues(RecordType)); // => [0, 1]\n * ```\n */\nexport function getEnumNumberValues<T extends Record<string, any>>(enumObject: T): Extract<T[keyof T], number>[] {\n return getEnumValues(enumObject).filter((value) => typeof value === 'number');\n}\n\n/**\n * Extracts only the string values from an enumeration-like object.\n *\n * @typeParam T - The type of the enum object.\n *\n * @param enumObject - The enumeration-like object to extract string values from,\n * the object can contain numeric values, string values, or both.\n *\n * @returns An array of string values extracted from the enum object.\n *\n * @example\n *\n * ```ts\n * import { getEnumStringValues } from '@kikiutils/shared/enum';\n *\n * enum RecordType {\n * Receive = 0,\n * Send = 1,\n * Unknown = 'unknown',\n * }\n *\n * console.log(getEnumStringValues(RecordType)); // => ['unknown']\n * ```\n */\nexport function getEnumStringValues<T extends Record<string, any>>(enumObject: T): Extract<T[keyof T], string>[] {\n return getEnumValues(enumObject).filter((value) => typeof value === 'string');\n}\n\n/**\n * Extracts all values from an enumeration-like object.\n *\n * @remarks\n * This function handles TypeScript enums correctly by accounting for the reverse mapping\n * that occurs with numeric enums. It works with pure numeric enums, pure string enums,\n * and mixed enums.\n *\n * @typeParam T - The type of the enum object.\n *\n * @param enumObject - The enumeration-like object to extract values from,\n * the object can contain numeric values, string values, or both.\n *\n * @returns An array containing all the values from the enum object.\n *\n * @example\n *\n * ```ts\n * import { getEnumValues } from '@kikiutils/shared/enum';\n *\n * // Numeric enum\n * enum Status {\n * Active = 0,\n * Inactive = 1,\n * Pending = 2,\n * }\n *\n * console.log(getEnumValues(Status)); // => [0, 1, 2]\n *\n * // String enum\n * enum Color {\n * Red = 'RED',\n * Green = 'GREEN',\n * Blue = 'BLUE',\n * }\n *\n * console.log(getEnumValues(Color)); // => ['RED', 'GREEN', 'BLUE']\n *\n * // Mixed enum\n * enum RecordType {\n * Receive = 0,\n * Send = 1,\n * Unknown = 'unknown',\n * }\n *\n * console.log(getEnumValues(RecordType)); // => [0, 1, 'unknown']\n * ```\n */\nexport function getEnumValues<T extends Record<string, any>>(enumObject: T): (T[keyof T])[] {\n const values = Object.values(enumObject);\n const hasNumberValues = values.some((value) => typeof value === 'number');\n if (!hasNumberValues) return values;\n return Object.keys(enumObject).filter((key) => Number.isNaN(Number(key))).map((key) => enumObject[key]);\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;AAwBA,SAAgB,oBAAmD,YAA8C;CAC7G,OAAO,cAAc,UAAU,CAAC,CAAC,QAAQ,UAAU,OAAO,UAAU,QAAQ;AAChF;;;;;;;;;;;;;;;;;;;;;;;;;AA0BA,SAAgB,oBAAmD,YAA8C;CAC7G,OAAO,cAAc,UAAU,CAAC,CAAC,QAAQ,UAAU,OAAO,UAAU,QAAQ;AAChF;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAkDA,SAAgB,cAA6C,YAA+B;CACxF,MAAM,SAAS,OAAO,OAAO,UAAU;CAEvC,IAAI,CADoB,OAAO,MAAM,UAAU,OAAO,UAAU,QAC7C,GAAG,OAAO;CAC7B,OAAO,OAAO,KAAK,UAAU,CAAC,CAAC,QAAQ,QAAQ,OAAO,MAAM,OAAO,GAAG,CAAC,CAAC,CAAC,CAAC,KAAK,QAAQ,WAAW,IAAI;AAC1G"}
package/dist/env.d.ts CHANGED
@@ -2,43 +2,50 @@
2
2
  /**
3
3
  * Custom error class for handling missing environment variables.
4
4
  *
5
+ * @remarks
5
6
  * Extends the built-in `Error` class and includes the missing key.
6
- *
7
- * @extends {Error}
8
7
  */
9
- declare class EnvironmentNotFoundError extends Error {
8
+ export declare class EnvironmentNotFoundError extends Error {
10
9
  readonly key: string;
11
10
  /**
12
- * Creates a new EnvironmentNotFoundError.
11
+ * Creates an error identifying a missing environment variable.
13
12
  *
14
- * @param {string} key - The missing environment variable key
13
+ * @param key - The missing environment variable key.
15
14
  */
16
15
  constructor(key: string);
17
16
  }
18
17
  /**
19
18
  * Retrieves the value of an environment variable, or throws an error if it is not defined.
20
19
  *
21
- * Only checks for `process.env[key] === undefined`. An empty string (e.g. '') or any falsy string
20
+ * @remarks
21
+ * Only checks for `process.env[key] === undefined`. An empty string (for example `''`) or any falsy string
22
22
  * value like `'0'` or `'false'` is considered a valid (defined) value.
23
23
  *
24
- * @param {string} key - The environment variable key to retrieve
24
+ * @param key - The environment variable key to retrieve.
25
25
  *
26
- * @returns {string} The value of the environment variable
26
+ * @returns The value of the environment variable.
27
27
  *
28
- * @throws {EnvironmentNotFoundError} If the environment variable is not defined
28
+ * @throws EnvironmentNotFoundError if the environment variable is not defined.
29
29
  *
30
30
  * @example
31
- * ```typescript
32
- * import { checkAndGetEnvValue } from '@kikiutils/shared/env';
31
+ *
32
+ * ```ts
33
+ * import {
34
+ * checkAndGetEnvValue,
35
+ * EnvironmentNotFoundError,
36
+ * } from '@kikiutils/shared/env';
33
37
  *
34
38
  * process.env.API_KEY = '';
35
- * checkAndGetEnvValue('API_KEY'); // ✅ Returns '' (still considered "defined")
39
+ * checkAndGetEnvValue('API_KEY'); // => ''
36
40
  *
37
41
  * delete process.env.API_KEY;
38
- * checkAndGetEnvValue('API_KEY'); // ❌ Throws EnvironmentNotFoundError
42
+ * try {
43
+ * checkAndGetEnvValue('API_KEY');
44
+ * } catch (error) {
45
+ * console.log(error instanceof EnvironmentNotFoundError); // => true
46
+ * }
39
47
  * ```
40
48
  */
41
- declare function checkAndGetEnvValue(key: string): string;
49
+ export declare function checkAndGetEnvValue(key: string): string;
42
50
  //#endregion
43
- export { EnvironmentNotFoundError, checkAndGetEnvValue };
44
51
  //# sourceMappingURL=env.d.ts.map
package/dist/env.d.ts.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"env.d.ts","names":[],"sources":["../src/env.ts"],"mappings":";;;;;;;;cAOa,iCAAiC;WACjC;;;;;;EAOG,YAAA;;;;;;;;;;;;;;;;;;;;;;;;;iBA+BA,oBAAoB"}
1
+ {"version":3,"file":"env.d.ts","names":[],"sources":["../src/env.ts"],"mappings":";;;;;;;qBAMa,iCAAiC;WACjC;;;;;;EAOG,YAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;wBAwCA,oBAAoB"}
package/dist/env.js CHANGED
@@ -2,16 +2,15 @@
2
2
  /**
3
3
  * Custom error class for handling missing environment variables.
4
4
  *
5
+ * @remarks
5
6
  * Extends the built-in `Error` class and includes the missing key.
6
- *
7
- * @extends {Error}
8
7
  */
9
8
  var EnvironmentNotFoundError = class extends Error {
10
9
  key;
11
10
  /**
12
- * Creates a new EnvironmentNotFoundError.
11
+ * Creates an error identifying a missing environment variable.
13
12
  *
14
- * @param {string} key - The missing environment variable key
13
+ * @param key - The missing environment variable key.
15
14
  */
16
15
  constructor(key) {
17
16
  super(`Missing environment variable: ${key}`);
@@ -23,24 +22,33 @@ var EnvironmentNotFoundError = class extends Error {
23
22
  /**
24
23
  * Retrieves the value of an environment variable, or throws an error if it is not defined.
25
24
  *
26
- * Only checks for `process.env[key] === undefined`. An empty string (e.g. '') or any falsy string
25
+ * @remarks
26
+ * Only checks for `process.env[key] === undefined`. An empty string (for example `''`) or any falsy string
27
27
  * value like `'0'` or `'false'` is considered a valid (defined) value.
28
28
  *
29
- * @param {string} key - The environment variable key to retrieve
29
+ * @param key - The environment variable key to retrieve.
30
30
  *
31
- * @returns {string} The value of the environment variable
31
+ * @returns The value of the environment variable.
32
32
  *
33
- * @throws {EnvironmentNotFoundError} If the environment variable is not defined
33
+ * @throws EnvironmentNotFoundError if the environment variable is not defined.
34
34
  *
35
35
  * @example
36
- * ```typescript
37
- * import { checkAndGetEnvValue } from '@kikiutils/shared/env';
36
+ *
37
+ * ```ts
38
+ * import {
39
+ * checkAndGetEnvValue,
40
+ * EnvironmentNotFoundError,
41
+ * } from '@kikiutils/shared/env';
38
42
  *
39
43
  * process.env.API_KEY = '';
40
- * checkAndGetEnvValue('API_KEY'); // ✅ Returns '' (still considered "defined")
44
+ * checkAndGetEnvValue('API_KEY'); // => ''
41
45
  *
42
46
  * delete process.env.API_KEY;
43
- * checkAndGetEnvValue('API_KEY'); // ❌ Throws EnvironmentNotFoundError
47
+ * try {
48
+ * checkAndGetEnvValue('API_KEY');
49
+ * } catch (error) {
50
+ * console.log(error instanceof EnvironmentNotFoundError); // => true
51
+ * }
44
52
  * ```
45
53
  */
46
54
  function checkAndGetEnvValue(key) {
package/dist/env.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"env.js","names":[],"sources":["../src/env.ts"],"sourcesContent":["/**\n * Custom error class for handling missing environment variables.\n *\n * Extends the built-in `Error` class and includes the missing key.\n *\n * @extends {Error}\n */\nexport class EnvironmentNotFoundError extends Error {\n readonly key: string;\n\n /**\n * Creates a new EnvironmentNotFoundError.\n *\n * @param {string} key - The missing environment variable key\n */\n constructor(key: string) {\n super(`Missing environment variable: ${key}`);\n this.key = key;\n this.name = this.constructor.name;\n Error.captureStackTrace?.(this, this.constructor);\n }\n}\n\n/**\n * Retrieves the value of an environment variable, or throws an error if it is not defined.\n *\n * Only checks for `process.env[key] === undefined`. An empty string (e.g. '') or any falsy string\n * value like `'0'` or `'false'` is considered a valid (defined) value.\n *\n * @param {string} key - The environment variable key to retrieve\n *\n * @returns {string} The value of the environment variable\n *\n * @throws {EnvironmentNotFoundError} If the environment variable is not defined\n *\n * @example\n * ```typescript\n * import { checkAndGetEnvValue } from '@kikiutils/shared/env';\n *\n * process.env.API_KEY = '';\n * checkAndGetEnvValue('API_KEY'); // ✅ Returns '' (still considered \"defined\")\n *\n * delete process.env.API_KEY;\n * checkAndGetEnvValue('API_KEY'); // ❌ Throws EnvironmentNotFoundError\n * ```\n */\nexport function checkAndGetEnvValue(key: string) {\n if (process.env[key] === undefined) throw new EnvironmentNotFoundError(key);\n return process.env[key];\n}\n"],"mappings":";;;;;;;;AAOA,IAAa,2BAAb,cAA8C,MAAM;CAChD;;;;;;CAOA,YAAY,KAAa;EACrB,MAAM,iCAAiC,KAAK;EAC5C,KAAK,MAAM;EACX,KAAK,OAAO,KAAK,YAAY;EAC7B,MAAM,oBAAoB,MAAM,KAAK,WAAW;CACpD;AACJ;;;;;;;;;;;;;;;;;;;;;;;;AAyBA,SAAgB,oBAAoB,KAAa;CAC7C,IAAI,QAAQ,IAAI,SAAS,KAAA,GAAW,MAAM,IAAI,yBAAyB,GAAG;CAC1E,OAAO,QAAQ,IAAI;AACvB"}
1
+ {"version":3,"file":"env.js","names":[],"sources":["../src/env.ts"],"sourcesContent":["/**\n * Custom error class for handling missing environment variables.\n *\n * @remarks\n * Extends the built-in `Error` class and includes the missing key.\n */\nexport class EnvironmentNotFoundError extends Error {\n readonly key: string;\n\n /**\n * Creates an error identifying a missing environment variable.\n *\n * @param key - The missing environment variable key.\n */\n constructor(key: string) {\n super(`Missing environment variable: ${key}`);\n this.key = key;\n this.name = this.constructor.name;\n Error.captureStackTrace?.(this, this.constructor);\n }\n}\n\n/**\n * Retrieves the value of an environment variable, or throws an error if it is not defined.\n *\n * @remarks\n * Only checks for `process.env[key] === undefined`. An empty string (for example `''`) or any falsy string\n * value like `'0'` or `'false'` is considered a valid (defined) value.\n *\n * @param key - The environment variable key to retrieve.\n *\n * @returns The value of the environment variable.\n *\n * @throws EnvironmentNotFoundError if the environment variable is not defined.\n *\n * @example\n *\n * ```ts\n * import {\n * checkAndGetEnvValue,\n * EnvironmentNotFoundError,\n * } from '@kikiutils/shared/env';\n *\n * process.env.API_KEY = '';\n * checkAndGetEnvValue('API_KEY'); // => ''\n *\n * delete process.env.API_KEY;\n * try {\n * checkAndGetEnvValue('API_KEY');\n * } catch (error) {\n * console.log(error instanceof EnvironmentNotFoundError); // => true\n * }\n * ```\n */\nexport function checkAndGetEnvValue(key: string) {\n if (process.env[key] === undefined) throw new EnvironmentNotFoundError(key);\n return process.env[key];\n}\n"],"mappings":";;;;;;;AAMA,IAAa,2BAAb,cAA8C,MAAM;CAChD;;;;;;CAOA,YAAY,KAAa;EACrB,MAAM,iCAAiC,KAAK;EAC5C,KAAK,MAAM;EACX,KAAK,OAAO,KAAK,YAAY;EAC7B,MAAM,oBAAoB,MAAM,KAAK,WAAW;CACpD;AACJ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAkCA,SAAgB,oBAAoB,KAAa;CAC7C,IAAI,QAAQ,IAAI,SAAS,KAAA,GAAW,MAAM,IAAI,yBAAyB,GAAG;CAC1E,OAAO,QAAQ,IAAI;AACvB"}
@@ -1,84 +1,79 @@
1
1
  //#region src/event-awaiter.d.ts
2
2
  /**
3
- * EventAwaiter provides a mechanism to wait for events (by key) asynchronously.
3
+ * An asynchronous keyed event rendezvous for one or more waiting consumers.
4
4
  *
5
- * This class allows multiple consumers to `wait` for a specific key
6
- * and be resolved when `trigger` is called for that key, or automatically
7
- * resolved with `undefined` if a timeout occurs or an AbortSignal is triggered.
5
+ * @remarks
6
+ * Triggers resolve the currently registered waiters; values are not retained for future waits.
7
+ * Timeouts and subsequent abort events resolve affected waiters with `undefined`.
8
+ * Use `triggerAll` to resolve pending waits during cleanup. Timers and abort listeners are not proactively
9
+ * removed by triggers, so they may remain until their timeout or abort event occurs.
8
10
  *
9
- * Typical use cases include long-polling, request coordination,
10
- * or implementing event-driven primitives in applications or services.
11
- *
12
- * @template T - The type of value that will be resolved when the event is triggered
11
+ * @typeParam T - The value delivered to waiting consumers.
13
12
  */
14
- declare class EventAwaiter<T> {
13
+ export declare class EventAwaiter<T> {
15
14
  #private;
16
15
  /**
17
- * Triggers all pending promises waiting for the given key.
18
- * Each promise will be resolved with the provided value.
16
+ * Resolves all currently pending waits for a key with the supplied value.
19
17
  *
20
- * @param {string} key - Identifier for the awaited event
21
- * @param {T | undefined} value - The value to resolve the awaiting promises with.
22
- * May be `undefined` to indicate no result or a timeout-like behavior.
18
+ * @param key - The event identifier; a key without pending waits has no effect.
19
+ * @param value - The delivered value; `undefined` indicates no result.
23
20
  */
24
21
  trigger(key: string, value: T | undefined): void;
25
22
  /**
26
- * Triggers and resolves all pending promises across all keys.
27
- *
28
- * This is typically used during shutdown or cleanup to ensure that
29
- * no consumer is left waiting indefinitely.
23
+ * Resolves all currently pending waits and clears their registrations.
30
24
  *
31
- * @param {T | undefined} [value] - Optional value to resolve all waiters with.
32
- * Defaults to `undefined`, which usually indicates cancellation or shutdown.
25
+ * @param value - The delivered value; omission resolves all pending waits with `undefined`.
33
26
  */
34
27
  triggerAll(value?: T | undefined): void;
35
28
  /**
36
- * Waits for an event associated with the given key.
29
+ * Waits for a trigger associated with a key.
37
30
  *
38
- * The returned promise will resolve when:
39
- * - `trigger(key)` is called, in which case it resolves with the provided value.
40
- * - The optional timeout is reached, in which case it resolves with `undefined`.
41
- * - The optional `AbortSignal` is aborted, in which case it resolves with `undefined`.
31
+ * @remarks
32
+ * By default, multiple waiters share a key and all receive the next trigger value.
33
+ * `strict` mode rejects duplicate waits; `override` mode resolves existing waits with `undefined` before
34
+ * registering the new wait. Timeout and abort remove only the affected waiter's registration.
35
+ * An already aborted signal is not checked; only an abort event emitted after registration ends the wait.
36
+ * Without a timeout or subsequent abort, the wait remains pending until a trigger arrives.
42
37
  *
43
- * Behavior when multiple waiters exist for the same key:
44
- * - Default (no mode): multiple waiters are allowed, all will be resolved when triggered.
45
- * - `strict` mode: throws an error if a waiter already exists for the given key.
46
- * - `override` mode: cancels all existing waiters (resolving them with `undefined`)
47
- * and only keeps the latest one.
38
+ * @param key - The event identifier to wait for.
39
+ * @param timeoutMs - The optional timeout in milliseconds, using native `setTimeout` timing rules.
40
+ * @param mode - The policy for existing waiters; omission allows multiple waiters.
41
+ * @param signal - A signal whose subsequent abort event ends this wait.
48
42
  *
49
- * @param {string} key - Identifier for the awaited event
50
- * @param {number} [timeoutMs] - Optional timeout (in milliseconds).
51
- * If reached, the promise resolves with `undefined`.
52
- * @param {'override' | 'strict'} [mode] - Optional behavior mode for handling multiple waiters
53
- * @param {AbortSignal} [signal] - Optional AbortSignal. If aborted, the promise resolves with `undefined`
43
+ * @returns A promise resolving to the triggered value, or `undefined` after timeout, abort, or replacement.
54
44
  *
55
- * @returns {Promise<T | undefined>} A promise that resolves with the triggered value,
56
- * or `undefined` if timeout or abort occurs
45
+ * @throws Error through promise rejection if `strict` mode encounters an existing waiter.
57
46
  */
58
47
  wait(key: string, timeoutMs?: number, mode?: 'override' | 'strict', signal?: AbortSignal): Promise<T | undefined>;
59
48
  /**
60
- * Waits for an event in strict mode.
61
- * Only one waiter is allowed per key. If another waiter already exists,
62
- * this method will throw an error.
49
+ * Waits for a key while rejecting duplicate registrations.
50
+ *
51
+ * @param key - The event identifier to wait for.
52
+ * @param timeoutMs - The optional timeout in milliseconds.
53
+ * @param signal - A signal whose subsequent abort event ends this wait; an already aborted signal is not checked.
54
+ *
55
+ * @returns A promise resolving to the triggered value, or `undefined` on timeout or subsequent abort.
63
56
  *
64
- * @param {string} key - Identifier for the awaited event
65
- * @param {number} [timeoutMs] - Optional timeout (in milliseconds).
66
- * If reached, the promise resolves with `undefined`.
67
- * @param {AbortSignal} [signal] - Optional AbortSignal. If aborted, the promise resolves with `undefined`
57
+ * @throws Error through promise rejection if the key already has a pending waiter.
58
+ *
59
+ * @see {@link EventAwaiter.wait}
68
60
  */
69
61
  waitExclusive(key: string, timeoutMs?: number, signal?: AbortSignal): Promise<T | undefined>;
70
62
  /**
71
- * Waits for an event in override mode.
72
- * If another waiter already exists for the given key, it will be canceled
73
- * (resolved with `undefined`) and replaced by the new waiter.
63
+ * Replaces existing waiters for a key and waits for its next trigger.
64
+ *
65
+ * @remarks
66
+ * Existing waiters resolve with `undefined` before the new waiter is registered.
67
+ *
68
+ * @param key - The event identifier to wait for.
69
+ * @param timeoutMs - The optional timeout in milliseconds.
70
+ * @param signal - A signal whose subsequent abort event ends this wait; an already aborted signal is not checked.
71
+ *
72
+ * @returns A promise resolving to the triggered value, or `undefined` on timeout, subsequent abort, or replacement.
74
73
  *
75
- * @param {string} key - Identifier for the awaited event
76
- * @param {number} [timeoutMs] - Optional timeout (in milliseconds).
77
- * If reached, the promise resolves with `undefined`.
78
- * @param {AbortSignal} [signal] - Optional AbortSignal. If aborted, the promise resolves with `undefined`
74
+ * @see {@link EventAwaiter.wait}
79
75
  */
80
76
  waitLatest(key: string, timeoutMs?: number, signal?: AbortSignal): Promise<T | undefined>;
81
77
  }
82
78
  //#endregion
83
- export { EventAwaiter };
84
79
  //# sourceMappingURL=event-awaiter.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"event-awaiter.d.ts","names":[],"sources":["../src/event-awaiter.ts"],"mappings":";;;;;;;;;;;;;cAYa,aAAa;;;;;;;;;;EAWtB,QAAQ,aAAa,OAAO;;;;;;;;;;EAiB5B,WAAW,QAAO;;;;;;;;;;;;;;;;;;;;;;;;EA4BlB,KAAK,aAAa,oBAAoB,8BAA8B,SAAS,cAAW,QAAA;;;;;;;;;;;EA2DxF,cAAc,aAAa,oBAAoB,SAAS,cAAW,QAAA;;;;;;;;;;;EAcnE,WAAW,aAAa,oBAAoB,SAAS,cAAW,QAAA"}
1
+ {"version":3,"file":"event-awaiter.d.ts","names":[],"sources":["../src/event-awaiter.ts"],"mappings":";;;;;;;;;;;;qBAWa,aAAa;;;;;;;;EAYtB,QAAQ,aAAa,OAAO;;;;;;EAa5B,WAAW,QAAO;;;;;;;;;;;;;;;;;;;;EAwBlB,KAAK,aAAa,oBAAoB,8BAA8B,SAAS,cAAW,QAAA;;;;;;;;;;;;;;EA8DxF,cAAc,aAAa,oBAAoB,SAAS,cAAW,QAAA;;;;;;;;;;;;;;;EAkBnE,WAAW,aAAa,oBAAoB,SAAS,cAAW,QAAA"}
@@ -1,25 +1,22 @@
1
1
  //#region src/event-awaiter.ts
2
2
  /**
3
- * EventAwaiter provides a mechanism to wait for events (by key) asynchronously.
3
+ * An asynchronous keyed event rendezvous for one or more waiting consumers.
4
4
  *
5
- * This class allows multiple consumers to `wait` for a specific key
6
- * and be resolved when `trigger` is called for that key, or automatically
7
- * resolved with `undefined` if a timeout occurs or an AbortSignal is triggered.
5
+ * @remarks
6
+ * Triggers resolve the currently registered waiters; values are not retained for future waits.
7
+ * Timeouts and subsequent abort events resolve affected waiters with `undefined`.
8
+ * Use `triggerAll` to resolve pending waits during cleanup. Timers and abort listeners are not proactively
9
+ * removed by triggers, so they may remain until their timeout or abort event occurs.
8
10
  *
9
- * Typical use cases include long-polling, request coordination,
10
- * or implementing event-driven primitives in applications or services.
11
- *
12
- * @template T - The type of value that will be resolved when the event is triggered
11
+ * @typeParam T - The value delivered to waiting consumers.
13
12
  */
14
13
  var EventAwaiter = class {
15
14
  #promiseResolvers = /* @__PURE__ */ new Map();
16
15
  /**
17
- * Triggers all pending promises waiting for the given key.
18
- * Each promise will be resolved with the provided value.
16
+ * Resolves all currently pending waits for a key with the supplied value.
19
17
  *
20
- * @param {string} key - Identifier for the awaited event
21
- * @param {T | undefined} value - The value to resolve the awaiting promises with.
22
- * May be `undefined` to indicate no result or a timeout-like behavior.
18
+ * @param key - The event identifier; a key without pending waits has no effect.
19
+ * @param value - The delivered value; `undefined` indicates no result.
23
20
  */
24
21
  trigger(key, value) {
25
22
  const resolvers = this.#promiseResolvers.get(key);
@@ -29,40 +26,32 @@ var EventAwaiter = class {
29
26
  }
30
27
  }
31
28
  /**
32
- * Triggers and resolves all pending promises across all keys.
33
- *
34
- * This is typically used during shutdown or cleanup to ensure that
35
- * no consumer is left waiting indefinitely.
29
+ * Resolves all currently pending waits and clears their registrations.
36
30
  *
37
- * @param {T | undefined} [value] - Optional value to resolve all waiters with.
38
- * Defaults to `undefined`, which usually indicates cancellation or shutdown.
31
+ * @param value - The delivered value; omission resolves all pending waits with `undefined`.
39
32
  */
40
33
  triggerAll(value = void 0) {
41
34
  for (const [_, resolvers] of this.#promiseResolvers.entries()) resolvers.forEach((resolve) => resolve(value));
42
35
  this.#promiseResolvers.clear();
43
36
  }
44
37
  /**
45
- * Waits for an event associated with the given key.
38
+ * Waits for a trigger associated with a key.
46
39
  *
47
- * The returned promise will resolve when:
48
- * - `trigger(key)` is called, in which case it resolves with the provided value.
49
- * - The optional timeout is reached, in which case it resolves with `undefined`.
50
- * - The optional `AbortSignal` is aborted, in which case it resolves with `undefined`.
40
+ * @remarks
41
+ * By default, multiple waiters share a key and all receive the next trigger value.
42
+ * `strict` mode rejects duplicate waits; `override` mode resolves existing waits with `undefined` before
43
+ * registering the new wait. Timeout and abort remove only the affected waiter's registration.
44
+ * An already aborted signal is not checked; only an abort event emitted after registration ends the wait.
45
+ * Without a timeout or subsequent abort, the wait remains pending until a trigger arrives.
51
46
  *
52
- * Behavior when multiple waiters exist for the same key:
53
- * - Default (no mode): multiple waiters are allowed, all will be resolved when triggered.
54
- * - `strict` mode: throws an error if a waiter already exists for the given key.
55
- * - `override` mode: cancels all existing waiters (resolving them with `undefined`)
56
- * and only keeps the latest one.
47
+ * @param key - The event identifier to wait for.
48
+ * @param timeoutMs - The optional timeout in milliseconds, using native `setTimeout` timing rules.
49
+ * @param mode - The policy for existing waiters; omission allows multiple waiters.
50
+ * @param signal - A signal whose subsequent abort event ends this wait.
57
51
  *
58
- * @param {string} key - Identifier for the awaited event
59
- * @param {number} [timeoutMs] - Optional timeout (in milliseconds).
60
- * If reached, the promise resolves with `undefined`.
61
- * @param {'override' | 'strict'} [mode] - Optional behavior mode for handling multiple waiters
62
- * @param {AbortSignal} [signal] - Optional AbortSignal. If aborted, the promise resolves with `undefined`
52
+ * @returns A promise resolving to the triggered value, or `undefined` after timeout, abort, or replacement.
63
53
  *
64
- * @returns {Promise<T | undefined>} A promise that resolves with the triggered value,
65
- * or `undefined` if timeout or abort occurs
54
+ * @throws Error through promise rejection if `strict` mode encounters an existing waiter.
66
55
  */
67
56
  wait(key, timeoutMs, mode, signal) {
68
57
  return new Promise((resolve) => {
@@ -97,27 +86,34 @@ var EventAwaiter = class {
97
86
  });
98
87
  }
99
88
  /**
100
- * Waits for an event in strict mode.
101
- * Only one waiter is allowed per key. If another waiter already exists,
102
- * this method will throw an error.
89
+ * Waits for a key while rejecting duplicate registrations.
90
+ *
91
+ * @param key - The event identifier to wait for.
92
+ * @param timeoutMs - The optional timeout in milliseconds.
93
+ * @param signal - A signal whose subsequent abort event ends this wait; an already aborted signal is not checked.
94
+ *
95
+ * @returns A promise resolving to the triggered value, or `undefined` on timeout or subsequent abort.
103
96
  *
104
- * @param {string} key - Identifier for the awaited event
105
- * @param {number} [timeoutMs] - Optional timeout (in milliseconds).
106
- * If reached, the promise resolves with `undefined`.
107
- * @param {AbortSignal} [signal] - Optional AbortSignal. If aborted, the promise resolves with `undefined`
97
+ * @throws Error through promise rejection if the key already has a pending waiter.
98
+ *
99
+ * @see {@link EventAwaiter.wait}
108
100
  */
109
101
  waitExclusive(key, timeoutMs, signal) {
110
102
  return this.wait(key, timeoutMs, "strict", signal);
111
103
  }
112
104
  /**
113
- * Waits for an event in override mode.
114
- * If another waiter already exists for the given key, it will be canceled
115
- * (resolved with `undefined`) and replaced by the new waiter.
105
+ * Replaces existing waiters for a key and waits for its next trigger.
106
+ *
107
+ * @remarks
108
+ * Existing waiters resolve with `undefined` before the new waiter is registered.
109
+ *
110
+ * @param key - The event identifier to wait for.
111
+ * @param timeoutMs - The optional timeout in milliseconds.
112
+ * @param signal - A signal whose subsequent abort event ends this wait; an already aborted signal is not checked.
113
+ *
114
+ * @returns A promise resolving to the triggered value, or `undefined` on timeout, subsequent abort, or replacement.
116
115
  *
117
- * @param {string} key - Identifier for the awaited event
118
- * @param {number} [timeoutMs] - Optional timeout (in milliseconds).
119
- * If reached, the promise resolves with `undefined`.
120
- * @param {AbortSignal} [signal] - Optional AbortSignal. If aborted, the promise resolves with `undefined`
116
+ * @see {@link EventAwaiter.wait}
121
117
  */
122
118
  waitLatest(key, timeoutMs, signal) {
123
119
  return this.wait(key, timeoutMs, "override", signal);