@oscarpalmer/atoms 0.186.2 → 0.187.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 (229) hide show
  1. package/dist/array/filter.d.mts +4 -4
  2. package/dist/array/find.d.mts +4 -4
  3. package/dist/array/first.d.mts +4 -4
  4. package/dist/array/get.d.mts +27 -1
  5. package/dist/array/get.mjs +5 -3
  6. package/dist/array/group-by.d.mts +6 -6
  7. package/dist/array/last.d.mts +4 -4
  8. package/dist/array/match.d.mts +7 -6
  9. package/dist/array/move.d.mts +7 -7
  10. package/dist/array/move.mjs +1 -1
  11. package/dist/array/select.d.mts +1 -0
  12. package/dist/array/slice.d.mts +3 -3
  13. package/dist/array/sort.d.mts +10 -7
  14. package/dist/array/sort.mjs +4 -3
  15. package/dist/array/swap.d.mts +1 -1
  16. package/dist/array/swap.mjs +1 -1
  17. package/dist/array/to-map.d.mts +32 -32
  18. package/dist/array/to-record.d.mts +6 -6
  19. package/dist/array/to-set.d.mts +6 -6
  20. package/dist/beacon.d.mts +6 -0
  21. package/dist/beacon.mjs +3 -0
  22. package/dist/color/index.d.mts +6 -2
  23. package/dist/color/index.mjs +6 -2
  24. package/dist/color/instance.d.mts +78 -14
  25. package/dist/color/instance.mjs +78 -14
  26. package/dist/color/misc/get.d.mts +39 -11
  27. package/dist/color/misc/get.mjs +39 -11
  28. package/dist/color/misc/is.d.mts +26 -11
  29. package/dist/color/misc/is.mjs +26 -11
  30. package/dist/color/misc/state.mjs +1 -1
  31. package/dist/color/models.d.mts +7 -4
  32. package/dist/color/space/hex.d.mts +15 -6
  33. package/dist/color/space/hex.mjs +15 -6
  34. package/dist/color/space/hsl.d.mts +10 -4
  35. package/dist/color/space/hsl.mjs +10 -4
  36. package/dist/color/space/rgb.d.mts +21 -12
  37. package/dist/color/space/rgb.mjs +21 -12
  38. package/dist/function/assert.d.mts +20 -14
  39. package/dist/function/assert.mjs +19 -13
  40. package/dist/function/limit.d.mts +8 -6
  41. package/dist/function/limit.mjs +8 -6
  42. package/dist/function/memoize.d.mts +15 -4
  43. package/dist/function/memoize.mjs +18 -4
  44. package/dist/function/once.d.mts +5 -3
  45. package/dist/function/once.mjs +5 -3
  46. package/dist/function/retry.d.mts +5 -2
  47. package/dist/function/retry.mjs +3 -1
  48. package/dist/function/work.d.mts +146 -98
  49. package/dist/{kalas.d.mts → herald.d.mts} +17 -8
  50. package/dist/{kalas.mjs → herald.mjs} +22 -13
  51. package/dist/index.d.mts +1464 -708
  52. package/dist/index.mjs +677 -324
  53. package/dist/internal/array/index-of.d.mts +4 -4
  54. package/dist/internal/array/insert.mjs +1 -1
  55. package/dist/internal/array/shuffle.d.mts +1 -0
  56. package/dist/internal/array/shuffle.mjs +2 -1
  57. package/dist/internal/is.d.mts +26 -8
  58. package/dist/internal/is.mjs +26 -8
  59. package/dist/internal/math/aggregate.d.mts +9 -9
  60. package/dist/internal/number.d.mts +13 -2
  61. package/dist/internal/number.mjs +13 -2
  62. package/dist/internal/random.d.mts +4 -2
  63. package/dist/internal/random.mjs +7 -5
  64. package/dist/internal/result.d.mts +17 -11
  65. package/dist/internal/result.mjs +10 -14
  66. package/dist/internal/string.d.mts +16 -1
  67. package/dist/internal/string.mjs +24 -1
  68. package/dist/internal/value/compare.d.mts +5 -2
  69. package/dist/internal/value/compare.mjs +5 -2
  70. package/dist/internal/value/equal.d.mts +12 -3
  71. package/dist/internal/value/equal.mjs +7 -4
  72. package/dist/internal/value/get.d.mts +17 -17
  73. package/dist/internal/value/has.d.mts +55 -11
  74. package/dist/internal/value/set.d.mts +24 -0
  75. package/dist/is.d.mts +12 -0
  76. package/dist/is.mjs +16 -1
  77. package/dist/logger.d.mts +7 -6
  78. package/dist/logger.mjs +6 -5
  79. package/dist/math.d.mts +36 -18
  80. package/dist/math.mjs +6 -3
  81. package/dist/models.d.mts +3 -3
  82. package/dist/promise/delay.d.mts +2 -0
  83. package/dist/promise/helpers.d.mts +6 -4
  84. package/dist/promise/helpers.mjs +6 -4
  85. package/dist/promise/index.d.mts +49 -38
  86. package/dist/promise/misc.d.mts +10 -7
  87. package/dist/promise/misc.mjs +4 -3
  88. package/dist/promise/models.d.mts +18 -19
  89. package/dist/promise/models.mjs +4 -3
  90. package/dist/promise/timed.d.mts +8 -6
  91. package/dist/query.d.mts +2 -0
  92. package/dist/query.mjs +2 -0
  93. package/dist/queue.d.mts +15 -4
  94. package/dist/queue.mjs +10 -3
  95. package/dist/random.d.mts +9 -2
  96. package/dist/random.mjs +7 -2
  97. package/dist/result/index.d.mts +14 -8
  98. package/dist/result/match.d.mts +18 -10
  99. package/dist/result/misc.d.mts +14 -7
  100. package/dist/result/misc.mjs +4 -2
  101. package/dist/result/models.d.mts +2 -0
  102. package/dist/result/work/flow.d.mts +86 -62
  103. package/dist/result/work/pipe.d.mts +55 -33
  104. package/dist/sized/map.d.mts +19 -16
  105. package/dist/sized/map.mjs +4 -4
  106. package/dist/sized/set.d.mts +20 -16
  107. package/dist/sized/set.mjs +8 -7
  108. package/dist/string/case.d.mts +8 -0
  109. package/dist/string/case.mjs +8 -0
  110. package/dist/string/fuzzy.d.mts +19 -5
  111. package/dist/string/fuzzy.mjs +7 -0
  112. package/dist/string/index.d.mts +17 -2
  113. package/dist/string/index.mjs +7 -9
  114. package/dist/string/match.d.mts +3 -0
  115. package/dist/string/match.mjs +3 -0
  116. package/dist/string/normalize.d.mts +6 -2
  117. package/dist/string/normalize.mjs +5 -2
  118. package/dist/string/template.d.mts +38 -9
  119. package/dist/string/template.mjs +19 -19
  120. package/dist/value/clone.d.mts +25 -4
  121. package/dist/value/clone.mjs +36 -22
  122. package/dist/value/collection.d.mts +9 -6
  123. package/dist/value/collection.mjs +3 -2
  124. package/dist/value/diff.d.mts +3 -1
  125. package/dist/value/diff.mjs +1 -0
  126. package/dist/value/freeze.d.mts +118 -9
  127. package/dist/value/freeze.mjs +56 -14
  128. package/dist/value/index.d.mts +1 -2
  129. package/dist/value/index.mjs +1 -2
  130. package/dist/value/merge.d.mts +11 -5
  131. package/dist/value/merge.mjs +2 -2
  132. package/dist/value/omit.d.mts +1 -0
  133. package/dist/value/omit.mjs +1 -0
  134. package/dist/value/pick.d.mts +1 -0
  135. package/dist/value/pick.mjs +1 -0
  136. package/dist/value/shake.d.mts +1 -0
  137. package/dist/value/shake.mjs +1 -0
  138. package/dist/value/smush.d.mts +1 -0
  139. package/dist/value/smush.mjs +1 -0
  140. package/dist/value/transform.d.mts +7 -3
  141. package/dist/value/unsmush.d.mts +1 -0
  142. package/dist/value/unsmush.mjs +1 -0
  143. package/package.json +11 -7
  144. package/src/array/filter.ts +4 -4
  145. package/src/array/find.ts +4 -4
  146. package/src/array/first.ts +4 -4
  147. package/src/array/get.ts +40 -5
  148. package/src/array/group-by.ts +6 -6
  149. package/src/array/last.ts +4 -4
  150. package/src/array/match.ts +7 -6
  151. package/src/array/move.ts +7 -7
  152. package/src/array/select.ts +1 -0
  153. package/src/array/slice.ts +3 -3
  154. package/src/array/sort.ts +15 -10
  155. package/src/array/swap.ts +1 -1
  156. package/src/array/to-map.ts +32 -32
  157. package/src/array/to-record.ts +6 -6
  158. package/src/array/to-set.ts +6 -6
  159. package/src/beacon.ts +6 -0
  160. package/src/color/index.ts +6 -2
  161. package/src/color/instance.ts +78 -14
  162. package/src/color/misc/get.ts +39 -11
  163. package/src/color/misc/is.ts +26 -11
  164. package/src/color/misc/state.ts +1 -1
  165. package/src/color/models.ts +7 -4
  166. package/src/color/space/hex.ts +15 -6
  167. package/src/color/space/hsl.ts +10 -4
  168. package/src/color/space/rgb.ts +21 -12
  169. package/src/function/assert.ts +20 -14
  170. package/src/function/limit.ts +8 -6
  171. package/src/function/memoize.ts +24 -5
  172. package/src/function/once.ts +5 -3
  173. package/src/function/retry.ts +7 -3
  174. package/src/function/work.ts +146 -98
  175. package/src/{kalas.ts → herald.ts} +23 -14
  176. package/src/index.ts +3 -2
  177. package/src/internal/array/index-of.ts +4 -4
  178. package/src/internal/array/insert.ts +1 -1
  179. package/src/internal/array/shuffle.ts +2 -1
  180. package/src/internal/is.ts +26 -8
  181. package/src/internal/math/aggregate.ts +9 -9
  182. package/src/internal/number.ts +13 -2
  183. package/src/internal/random.ts +10 -4
  184. package/src/internal/result.ts +30 -29
  185. package/src/internal/string.ts +28 -0
  186. package/src/internal/value/compare.ts +5 -2
  187. package/src/internal/value/equal.ts +13 -4
  188. package/src/internal/value/get.ts +17 -17
  189. package/src/internal/value/has.ts +54 -11
  190. package/src/internal/value/set.ts +24 -0
  191. package/src/is.ts +15 -1
  192. package/src/logger.ts +8 -7
  193. package/src/math.ts +36 -18
  194. package/src/models.ts +3 -3
  195. package/src/promise/delay.ts +2 -0
  196. package/src/promise/helpers.ts +6 -4
  197. package/src/promise/index.ts +49 -38
  198. package/src/promise/misc.ts +10 -7
  199. package/src/promise/models.ts +18 -19
  200. package/src/promise/timed.ts +8 -6
  201. package/src/query.ts +2 -0
  202. package/src/queue.ts +15 -4
  203. package/src/random.ts +8 -1
  204. package/src/result/index.ts +14 -8
  205. package/src/result/match.ts +18 -10
  206. package/src/result/misc.ts +17 -9
  207. package/src/result/models.ts +2 -0
  208. package/src/result/work/flow.ts +86 -62
  209. package/src/result/work/pipe.ts +55 -33
  210. package/src/sized/map.ts +20 -17
  211. package/src/sized/set.ts +21 -17
  212. package/src/string/case.ts +8 -0
  213. package/src/string/fuzzy.ts +19 -5
  214. package/src/string/index.ts +18 -15
  215. package/src/string/match.ts +3 -0
  216. package/src/string/normalize.ts +6 -2
  217. package/src/string/template.ts +69 -18
  218. package/src/value/clone.ts +51 -26
  219. package/src/value/collection.ts +9 -6
  220. package/src/value/diff.ts +3 -1
  221. package/src/value/freeze.ts +239 -25
  222. package/src/value/index.ts +0 -1
  223. package/src/value/merge.ts +11 -5
  224. package/src/value/omit.ts +1 -0
  225. package/src/value/pick.ts +1 -0
  226. package/src/value/shake.ts +1 -0
  227. package/src/value/smush.ts +1 -0
  228. package/src/value/transform.ts +7 -3
  229. package/src/value/unsmush.ts +1 -0
@@ -68,18 +68,20 @@ export function getStrategyOrDefault(value: unknown): PromiseStrategy {
68
68
  }
69
69
 
70
70
  /**
71
- * Is the value a fulfilled promise result?
71
+ * Is the value a fulfilled _Promise_ result?
72
+ *
72
73
  * @param value Value to check
73
- * @returns `true` if the value is a fulfilled promise result, `false` otherwise
74
+ * @returns `true` if the value is a fulfilled _Promise_ result, `false` otherwise
74
75
  */
75
76
  export function isFulfilled<Value>(value: unknown): value is FulfilledPromise<Value> {
76
77
  return isType(value, PROMISE_TYPE_FULFILLED);
77
78
  }
78
79
 
79
80
  /**
80
- * Is the value a rejected promise result?
81
+ * Is the value a rejected _Promise_ result?
82
+ *
81
83
  * @param value Value to check
82
- * @returns `true` if the value is a rejected promise result, `false` otherwise
84
+ * @returns `true` if the value is a rejected _Promise_ result, `false` otherwise
83
85
  */
84
86
  export function isRejected(value: unknown): value is RejectedPromise {
85
87
  return isType(value, PROMISE_TYPE_REJECTED);
@@ -23,10 +23,11 @@ import {getTimedPromise} from './timed';
23
23
  // #region Functions
24
24
 
25
25
  /**
26
- * Wrap a promise with safety handlers, with optional abort capabilities and timeout
27
- * @param promise Promise to wrap
28
- * @param options Options for the promise
29
- * @returns Wrapped promise
26
+ * Wrap a _Promise_ with safety handlers, with optional abort capabilities and timeout
27
+ *
28
+ * @param promise _Promise_ to wrap
29
+ * @param options Options for the _Promise_
30
+ * @returns Wrapped _Promise_
30
31
  */
31
32
  export async function attemptPromise<Value>(
32
33
  promise: Promise<Value>,
@@ -34,10 +35,11 @@ export async function attemptPromise<Value>(
34
35
  ): Promise<Value>;
35
36
 
36
37
  /**
37
- * Wrap a promise-returning callback with safety handlers, with optional abort capabilities and timeout
38
+ * Wrap a _Promise_-returning callback with safety handlers, with optional abort capabilities and timeout
39
+ *
38
40
  * @param callback Callback to wrap
39
- * @param options Options for the promise
40
- * @returns Promise-wrapped callback
41
+ * @param options Options for the _Promise_
42
+ * @returns _Promise_-wrapped callback
41
43
  */
42
44
  export async function attemptPromise<Value>(
43
45
  callback: () => Promise<Value>,
@@ -45,10 +47,11 @@ export async function attemptPromise<Value>(
45
47
  ): Promise<Value>;
46
48
 
47
49
  /**
48
- * Wrap a callback with a promise and safety handlers, with optional abort capabilities and timeout
50
+ * Wrap a callback with a _Promise_ and safety handlers, with optional abort capabilities and timeout
51
+ *
49
52
  * @param callback Callback to wrap
50
- * @param options Options for the promise
51
- * @returns Promise-wrapped callback
53
+ * @param options Options for the _Promise_
54
+ * @returns _Promise_-wrapped callback
52
55
  */
53
56
  export async function attemptPromise<Value>(
54
57
  callback: () => Value,
@@ -106,11 +109,12 @@ export async function attemptPromise<Value>(
106
109
  }
107
110
 
108
111
  /**
109
- * Handle a list of promises, returning their results in an ordered array.
112
+ * Handle a list of _Promises_, returning their results in an ordered array
110
113
  *
111
114
  * Depending on the strategy, the function will either reject on the first error encountered or return an array of rejected and resolved results
112
- * @param items List of promises
113
- * @param options Options for handling the promises
115
+ *
116
+ * @param items List of _Promises_
117
+ * @param options Options for handling the _Promises_
114
118
  * @returns List of results
115
119
  */
116
120
  export async function promises<Items extends unknown[], Options extends PromisesOptions>(
@@ -123,11 +127,12 @@ export async function promises<Items extends unknown[], Options extends Promises
123
127
  >;
124
128
 
125
129
  /**
126
- * Handle a list of promises, returning their results in an ordered array.
130
+ * Handle a list of _Promises_, returning their results in an ordered array
127
131
  *
128
132
  * Depending on the strategy, the function will either reject on the first error encountered or return an array of rejected and resolved results
129
- * @param items List of promises
130
- * @param options Options for handling the promises
133
+ *
134
+ * @param items List of _Promises_
135
+ * @param options Options for handling the _Promises_
131
136
  * @returns List of results
132
137
  */
133
138
  export async function promises<Value, Options extends PromisesOptions>(
@@ -136,11 +141,12 @@ export async function promises<Value, Options extends PromisesOptions>(
136
141
  ): Promise<Options['strategy'] extends 'first' ? Value[] : PromisesValue<Value>[]>;
137
142
 
138
143
  /**
139
- * Handle a list of promises, returning their results in an ordered array.
144
+ * Handle a list of _Promises_, returning their results in an ordered array
145
+ *
146
+ * If any _Promise_ in the list is rejected, the whole function will reject
140
147
  *
141
- * If any promise in the list is rejected, the whole function will reject
142
- * @param items List of promises
143
- * @param strategy Strategy for handling the promises; rejects on the first error encountered
148
+ * @param items List of _Promises_
149
+ * @param strategy Strategy for handling the _Promises_; rejects on the first error encountered
144
150
  * @returns List of results
145
151
  */
146
152
  export async function promises<Items extends unknown[]>(
@@ -149,19 +155,21 @@ export async function promises<Items extends unknown[]>(
149
155
  ): Promise<PromisesUnwrapped<Items>>;
150
156
 
151
157
  /**
152
- * Handle a list of promises, returning their results in an ordered array.
158
+ * Handle a list of _Promises_, returning their results in an ordered array
153
159
  *
154
- * If any promise in the list is rejected, the whole function will reject
155
- * @param items List of promises
156
- * @param strategy Strategy for handling the promises; rejects on the first error encountered
160
+ * If any _Promise_ in the list is rejected, the whole function will reject
161
+ *
162
+ * @param items List of _Promises_
163
+ * @param strategy Strategy for handling the _Promises_; rejects on the first error encountered
157
164
  * @returns List of results
158
165
  */
159
166
  export async function promises<Value>(items: Promise<Value>[], strategy: 'first'): Promise<Value[]>;
160
167
 
161
168
  /**
162
- * Handle a list of promises, returning their results in an ordered array of rejected and resolved results
163
- * @param items List of promises
164
- * @param signal AbortSignal for aborting the operation _(when aborted, the promise will reject with the reason of the signal)_
169
+ * Handle a list of _Promises_, returning their results in an ordered array of rejected and resolved results
170
+ *
171
+ * @param items List of _Promises_
172
+ * @param signal AbortSignal for aborting the operation _(when aborted, the _Promise_ will reject with the reason of the signal)_
165
173
  * @returns List of results
166
174
  */
167
175
  export async function promises<Items extends unknown[]>(
@@ -170,9 +178,10 @@ export async function promises<Items extends unknown[]>(
170
178
  ): Promise<PromisesValues<PromisesItems<Items>>>;
171
179
 
172
180
  /**
173
- * Handle a list of promises, returning their results in an ordered array of rejected and resolved results
174
- * @param items List of promises
175
- * @param signal AbortSignal for aborting the operation _(when aborted, the promise will reject with the reason of the signal)_
181
+ * Handle a list of _Promises_, returning their results in an ordered array of rejected and resolved results
182
+ *
183
+ * @param items List of _Promises_
184
+ * @param signal AbortSignal for aborting the operation _(when aborted, the _Promise_ will reject with the reason of the signal)_
176
185
  * @returns List of results
177
186
  */
178
187
  export async function promises<Value>(
@@ -250,13 +259,14 @@ export async function promises(items: unknown[], options?: unknown): Promise<unk
250
259
  promises.result = resultPromises;
251
260
 
252
261
  /**
253
- * Handle a list of promises, returning their results in an ordered array of results _({@link Result})_.
262
+ * Handle a list of _Promises_, returning their results in an ordered array of results _({@link Result})_
254
263
  *
255
264
  * Depending on the strategy, the function will either reject on the first error encountered or return an array of rejected and resolved results
256
265
  *
257
- * Available as `resultPromises` and `promises.result`
258
- * @param items List of promises
259
- * @param signal AbortSignal for aborting the operation _(when aborted, the promise will reject with the reason of the signal)_
266
+ * _Available as `resultPromises` and `promises.result`_
267
+ *
268
+ * @param items List of _Promises_
269
+ * @param signal AbortSignal for aborting the operation _(when aborted, the _Promise_ will reject with the reason of the signal)_
260
270
  * @returns List of results
261
271
  */
262
272
  export async function resultPromises<Items extends unknown[]>(
@@ -265,13 +275,14 @@ export async function resultPromises<Items extends unknown[]>(
265
275
  ): Promise<PromisesResult<PromisesItems<Items>>>;
266
276
 
267
277
  /**
268
- * Handle a list of promises, returning their results in an ordered array of results _({@link Result})_.
278
+ * Handle a list of _Promises_, returning their results in an ordered array of results _({@link Result})_
269
279
  *
270
280
  * Depending on the strategy, the function will either reject on the first error encountered or return an array of rejected and resolved results
271
281
  *
272
- * Available as `resultPromises` and `promises.result`
273
- * @param items List of promises
274
- * @param signal AbortSignal for aborting the operation _(when aborted, the promise will reject with the reason of the signal)_
282
+ * _Available as `resultPromises` and `promises.result`_
283
+ *
284
+ * @param items List of _Promises_
285
+ * @param signal AbortSignal for aborting the operation _(when aborted, the _Promise_ will reject with the reason of the signal)_
275
286
  * @returns List of results
276
287
  */
277
288
  export async function resultPromises<Value>(
@@ -12,9 +12,10 @@ import {
12
12
  // #region Functions
13
13
 
14
14
  /**
15
- * Create a cancelable promise
16
- * @param executor Executor function for the promise
17
- * @returns Cancelable promise
15
+ * Create a cancelable _Promise_
16
+ *
17
+ * @param executor Executor function for the _Promise_
18
+ * @returns Cancelable _Promise_
18
19
  */
19
20
  export function cancelable<Value>(
20
21
  executor: (resolve: (value: Value) => void, reject: (reason: unknown) => void) => void,
@@ -58,15 +59,17 @@ export function settlePromise(
58
59
  }
59
60
 
60
61
  /**
61
- * Converts a promise to a promised result
62
- * @param callback Promise callback
62
+ * Converts a _Promise_ to a promised result
63
+ *
64
+ * @param callback _Promise_ callback
63
65
  * @returns Promised result
64
66
  */
65
67
  export async function toResult<Value>(callback: () => Promise<Value>): Promise<Result<Value>>;
66
68
 
67
69
  /**
68
- * Converts a promise to a promised result
69
- * @param promise Promise to convert
70
+ * Converts a _Promise_ to a promised result
71
+ *
72
+ * @param promise _Promise_ to convert
70
73
  * @returns Promised result
71
74
  */
72
75
  export async function toResult<Value>(promise: Promise<Value>): Promise<Result<Value>>;
@@ -4,7 +4,7 @@ import type {Result} from '../result/models';
4
4
  // #region Types
5
5
 
6
6
  /**
7
- * A promise that can be canceled
7
+ * A _Promise_ that can be canceled
8
8
  */
9
9
  export class CancelablePromise<Value = void> extends Promise<Value> {
10
10
  #rejector!: (reason: unknown) => void;
@@ -24,8 +24,9 @@ export class CancelablePromise<Value = void> extends Promise<Value> {
24
24
  }
25
25
 
26
26
  /**
27
- * Cancel the promise, rejecting it with an optional reason
28
- * @param reason Optional reason for canceling the promise
27
+ * Cancel the _Promise_, rejecting it with an optional reason
28
+ *
29
+ * @param reason Optional reason for canceling the _Promise_
29
30
  */
30
31
  cancel(reason?: unknown): void {
31
32
  this.#rejector(reason);
@@ -33,15 +34,15 @@ export class CancelablePromise<Value = void> extends Promise<Value> {
33
34
  }
34
35
 
35
36
  /**
36
- * A promise that was fulfilled
37
+ * A _Promise_ that was fulfilled
37
38
  */
38
39
  export type FulfilledPromise<Value> = {
39
40
  /**
40
- * Status of the promise
41
+ * Status of the _Promise_
41
42
  */
42
43
  status: typeof PROMISE_TYPE_FULFILLED;
43
44
  /**
44
- * Value of the promise
45
+ * Value of the _Promise_
45
46
  */
46
47
  value: Awaited<Value>;
47
48
  };
@@ -57,15 +58,15 @@ export type PromiseHandlers = {
57
58
  };
58
59
 
59
60
  /**
60
- * Options for a promise-handling function
61
+ * Options for a _Promise_-handling function
61
62
  */
62
63
  export type PromiseOptions = {
63
64
  /**
64
- * AbortSignal for aborting the promise; when aborted, the promise will reject with the reason of the signal
65
+ * AbortSignal for aborting the _Promise_; when aborted, the _Promise_ will reject with the reason of the signal
65
66
  */
66
67
  signal?: AbortSignal;
67
68
  /**
68
- * How long to wait for (in milliseconds; defaults to `0`)
69
+ * How long to wait for _(in milliseconds; defaults to `0`)_
69
70
  */
70
71
  time?: number;
71
72
  };
@@ -81,12 +82,10 @@ export type PromiseParameters = {
81
82
  };
82
83
 
83
84
  /**
84
- * Promise handling strategy
85
+ * _Promise_ handling strategy
85
86
  *
86
- * - `complete`: wait for all promises to settle, then return the results
87
- * - Returns an array of fulfilled and/or rejected results
88
- * - `first`: rejects on the first rejected promise
89
- * - Returns an array of values
87
+ * - `complete`: wait for all _Promises_ to settle, then return the results, as an array of fulfilled and/or rejected results
88
+ * - `first`: rejects on the first rejected _Promise_, and returns an array of values
90
89
  */
91
90
  export type PromiseStrategy = 'complete' | 'first';
92
91
 
@@ -112,15 +111,15 @@ export type PromisesItems<Items extends unknown[]> = {
112
111
  };
113
112
 
114
113
  /**
115
- * Options for handling multiple promises
114
+ * Options for handling multiple _Promises_
116
115
  */
117
116
  export type PromisesOptions = {
118
117
  /**
119
- * AbortSignal for aborting the promises; when aborted, the promises will reject with the reason of the signal
118
+ * AbortSignal for aborting the _Promises_; when aborted, the _Promises_ will reject with the reason of the signal
120
119
  */
121
120
  signal?: AbortSignal;
122
121
  /**
123
- * Strategy for handling the promises; defaults to `complete`
122
+ * Strategy for handling the _Promises_; defaults to `complete`
124
123
  */
125
124
  strategy?: PromiseStrategy;
126
125
  };
@@ -154,11 +153,11 @@ export type PromisesValues<Items extends unknown[]> = {
154
153
  };
155
154
 
156
155
  /**
157
- * A promise that was rejected
156
+ * A _Promise_ that was rejected
158
157
  */
159
158
  export type RejectedPromise = {
160
159
  /**
161
- * Status of the promise
160
+ * Status of the _Promise_
162
161
  */
163
162
  status: typeof PROMISE_TYPE_REJECTED;
164
163
  /**
@@ -54,10 +54,11 @@ export async function getTimedPromise<Value>(
54
54
  }
55
55
 
56
56
  /**
57
- * Create a promise that should be settled within a certain amount of time
58
- * @param promise Promise to settle
57
+ * Create a _Promise_ that should be settled within a certain amount of time
58
+ *
59
+ * @param promise _Promise_ to settle
59
60
  * @param options Timed options
60
- * @returns Timed promise
61
+ * @returns Timed _Promise_
61
62
  */
62
63
  export async function timed<Value>(
63
64
  promise: Promise<Value>,
@@ -65,10 +66,11 @@ export async function timed<Value>(
65
66
  ): Promise<Value>;
66
67
 
67
68
  /**
68
- * Create a promise that should be settled within a certain amount of time
69
- * @param promise Promise to settle
69
+ * Create a _Promise_ that should be settled within a certain amount of time
70
+ *
71
+ * @param promise _Promise_ to settle
70
72
  * @param time How long to wait for _(in milliseconds; defaults to `0`)_
71
- * @returns Timed promise
73
+ * @returns Timed _Promise_
72
74
  */
73
75
  export async function timed<Value>(promise: Promise<Value>, time: number): Promise<Value>;
74
76
 
package/src/query.ts CHANGED
@@ -8,6 +8,7 @@ import type {ArrayOrPlainObject, PlainObject} from './models';
8
8
 
9
9
  /**
10
10
  * Convert a query string to a plain _(nested)_ object
11
+ *
11
12
  * @param query Query string to convert
12
13
  * @returns Plain object representation of the query string
13
14
  */
@@ -103,6 +104,7 @@ function setQueryValue(parameters: PlainObject, key: string, value: string): voi
103
104
 
104
105
  /**
105
106
  * Convert a plain _(nested)_ object to a query string
107
+ *
106
108
  * @param parameters Plain object to convert
107
109
  * @returns Query string representation of the object
108
110
  */
package/src/queue.ts CHANGED
@@ -16,7 +16,7 @@ class KeyedQueue<CallbackParameters extends Parameters<GenericAsyncCallback>, Ca
16
16
  readonly #queues: Map<string, Queue<Tail<CallbackParameters>, CallbackResult>> = new Map();
17
17
 
18
18
  /**
19
- * Is any queue active?
19
+ * Get keys of all active queues
20
20
  */
21
21
  get active(): string[] {
22
22
  return this.#getStatus(STATUS_ACTIVE);
@@ -37,14 +37,14 @@ class KeyedQueue<CallbackParameters extends Parameters<GenericAsyncCallback>, Ca
37
37
  }
38
38
 
39
39
  /**
40
- * Are all queues empty?
40
+ * Get keys of all empty queues
41
41
  */
42
42
  get empty(): string[] {
43
43
  return this.#getStatus(STATUS_EMPTY);
44
44
  }
45
45
 
46
46
  /**
47
- * Are all queues full?
47
+ * Get keys of all full queues
48
48
  */
49
49
  get full(): string[] {
50
50
  return this.#getStatus(STATUS_FULL);
@@ -100,6 +100,7 @@ class KeyedQueue<CallbackParameters extends Parameters<GenericAsyncCallback>, Ca
100
100
 
101
101
  /**
102
102
  * Queue an item for a specific key
103
+ *
103
104
  * @param key Key to queue the item for
104
105
  * @param parameters Parameters to use when item runs
105
106
  * @param signal Optional signal to abort the item
@@ -115,6 +116,7 @@ class KeyedQueue<CallbackParameters extends Parameters<GenericAsyncCallback>, Ca
115
116
 
116
117
  /**
117
118
  * Clear all items for a specific key _(or all items for all keys, if no key is provided)_
119
+ *
118
120
  * @param key Optional key to clear the queue for
119
121
  */
120
122
  clear(key?: string): void {
@@ -123,6 +125,7 @@ class KeyedQueue<CallbackParameters extends Parameters<GenericAsyncCallback>, Ca
123
125
 
124
126
  /**
125
127
  * Get the queue for a specific key
128
+ *
126
129
  * @param key Key to get the queue for
127
130
  * @returns Queue for the key, or `undefined` if it doesn't exist
128
131
  */
@@ -132,6 +135,7 @@ class KeyedQueue<CallbackParameters extends Parameters<GenericAsyncCallback>, Ca
132
135
 
133
136
  /**
134
137
  * Pause the queue for a specific key _(or all queues, if no key is provided)_
138
+ *
135
139
  * @param key Optional key to pause the queue for
136
140
  */
137
141
  pause(key?: string): void {
@@ -140,6 +144,7 @@ class KeyedQueue<CallbackParameters extends Parameters<GenericAsyncCallback>, Ca
140
144
 
141
145
  /**
142
146
  * Remove a specific item for a specific key
147
+ *
143
148
  * @param key Key to remove the item for
144
149
  * @param id ID of the item to remove
145
150
  */
@@ -149,6 +154,7 @@ class KeyedQueue<CallbackParameters extends Parameters<GenericAsyncCallback>, Ca
149
154
  * Remove a queue and its items for a specific key
150
155
  *
151
156
  * _(To remove all items for a specific key, use `clear()` instead)_
157
+ *
152
158
  * @param key Key to remove the queue for
153
159
  */
154
160
  remove(key: string): void;
@@ -186,6 +192,7 @@ class KeyedQueue<CallbackParameters extends Parameters<GenericAsyncCallback>, Ca
186
192
 
187
193
  /**
188
194
  * Resume the queue for a specific key _(or all queues, if no key is provided)_
195
+ *
189
196
  * @param key Optional key to resume the queue for
190
197
  */
191
198
  resume(key?: string): void {
@@ -329,6 +336,7 @@ class Queue<CallbackParameters extends Parameters<GenericAsyncCallback>, Callbac
329
336
 
330
337
  /**
331
338
  * Add an item to the queue
339
+ *
332
340
  * @param parameters Parameters to use when item runs
333
341
  * @param signal Optional signal to abort the item
334
342
  * @returns Queued item
@@ -404,6 +412,7 @@ class Queue<CallbackParameters extends Parameters<GenericAsyncCallback>, Callbac
404
412
 
405
413
  /**
406
414
  * Remove and reject a specific item in the queue
415
+ *
407
416
  * @param id ID of queued item
408
417
  */
409
418
  remove(id: number): void {
@@ -615,6 +624,7 @@ export function keyedQueue<Callback extends GenericAsyncCallback>(
615
624
 
616
625
  /**
617
626
  * Create a queue for an asynchronous callback function
627
+ *
618
628
  * @param callback Callback function for queued items
619
629
  * @param options Queue options
620
630
  * @returns Queue instance
@@ -625,7 +635,8 @@ export function queue<Callback extends (key: string, ...parameters: any[]) => Pr
625
635
  ): Queue<Parameters<Callback>, Awaited<ReturnType<Callback>>>;
626
636
 
627
637
  /**
628
- * Create a queue for an asynchronous callback function
638
+ * Create a queue for a synchronous callback function
639
+ *
629
640
  * @param callback Callback function for queued items
630
641
  * @param options Queue options
631
642
  * @returns Queue instance
package/src/random.ts CHANGED
@@ -6,6 +6,7 @@ import {join} from './internal/string';
6
6
 
7
7
  /**
8
8
  * Get a random boolean
9
+ *
9
10
  * @returns Random boolean
10
11
  */
11
12
  export function getRandomBoolean(): boolean {
@@ -14,6 +15,7 @@ export function getRandomBoolean(): boolean {
14
15
 
15
16
  /**
16
17
  * Get a random string of characters with a specified length
18
+ *
17
19
  * @param length Length of random string
18
20
  * @param selection String of characters to select from _(defaults to lowercase English alphabet)_
19
21
  * @returns Random string of characters
@@ -36,6 +38,7 @@ export function getRandomCharacters(length: number, selection?: string): string
36
38
 
37
39
  /**
38
40
  * Get a random hexadecimal color
41
+ *
39
42
  * @param prefix Prefix the color with `#`? _(defaults to `false`)_
40
43
  * @returns Random hexadecimal color string in the format `(#)RRGGBB`
41
44
  */
@@ -45,6 +48,7 @@ export function getRandomColor(prefix?: boolean): string {
45
48
 
46
49
  /**
47
50
  * Get a random hexadecimal character
51
+ *
48
52
  * @returns Random hexadecimal character from `0-9` and `A-F`
49
53
  */
50
54
  export function getRandomHex(): string {
@@ -53,6 +57,7 @@ export function getRandomHex(): string {
53
57
 
54
58
  /**
55
59
  * Get a random item from an array
60
+ *
56
61
  * @param array Array to get a random item from
57
62
  * @returns Random item from the array, or `undefined` if unable to retrieve one
58
63
  */
@@ -66,6 +71,7 @@ export function getRandomItem<Value>(array: Value[]): Value | undefined {
66
71
 
67
72
  /**
68
73
  * Get an amount of random items from an array
74
+ *
69
75
  * @param array Array to get random items from
70
76
  * @param amount Amount of items to return
71
77
  * @returns Array of random items
@@ -74,6 +80,7 @@ export function getRandomItems<Value>(array: Value[], amount: number): Value[];
74
80
 
75
81
  /**
76
82
  * Get a shuffled array
83
+ *
77
84
  * @param array Array to get random items from
78
85
  * @returns Shuffled version of the original array
79
86
  */
@@ -113,6 +120,6 @@ const HEX_MAXIMUM = 15;
113
120
 
114
121
  // #region Exports
115
122
 
116
- export {getRandomFloat, getRandomInteger} from './internal/random';
123
+ export {getRandomFloatingNumber as getRandomFloat, getRandomInteger} from './internal/random';
117
124
 
118
125
  // #endregion
@@ -4,10 +4,11 @@ import type {ExtendedErr, ExtendedResult, Result} from './models';
4
4
  // #region Functions
5
5
 
6
6
  /**
7
- * Executes a promise, catching any errors, and returns a result
7
+ * Executes a _Promise_, catching any errors, and returns a result
8
8
  *
9
- * Available as `asyncAttempt` and `attempt.async`
10
- * @param promise Promise to execute
9
+ * _Available as `asyncAttempt` and `attempt.async`_
10
+ *
11
+ * @param promise _Promise_ to execute
11
12
  * @param error Error value
12
13
  * @returns Callback result
13
14
  */
@@ -19,7 +20,8 @@ export async function asyncAttempt<Value, E>(
19
20
  /**
20
21
  * Executes a callback asynchronously, catching any errors, and returns a result
21
22
  *
22
- * Available as `asyncAttempt` and `attempt.async`
23
+ * _Available as `asyncAttempt` and `attempt.async`_
24
+ *
23
25
  * @param callback Callback to execute
24
26
  * @param error Error value
25
27
  * @returns Callback result
@@ -30,10 +32,11 @@ export async function asyncAttempt<Value, E>(
30
32
  ): Promise<ExtendedResult<Awaited<Value>, E>>;
31
33
 
32
34
  /**
33
- * Executes a promise, catching any errors, and returns a result
35
+ * Executes a _Promise_, catching any errors, and returns a result
36
+ *
37
+ * _Available as `asyncAttempt` and `attempt.async`_
34
38
  *
35
- * Available as `asyncAttempt` and `attempt.async`
36
- * @param promise Promise to execute
39
+ * @param promise _Promise_ to execute
37
40
  * @returns Callback result
38
41
  */
39
42
  export async function asyncAttempt<Value>(promise: Promise<Value>): Promise<Result<Awaited<Value>>>;
@@ -41,7 +44,8 @@ export async function asyncAttempt<Value>(promise: Promise<Value>): Promise<Resu
41
44
  /**
42
45
  * Executes a callback asynchronously, catching any errors, and returns a result
43
46
  *
44
- * Available as `asyncAttempt` and `attempt.async`
47
+ * _Available as `asyncAttempt` and `attempt.async`_
48
+ *
45
49
  * @param callback Callback to execute
46
50
  * @returns Callback result
47
51
  */
@@ -68,6 +72,7 @@ export async function asyncAttempt<Value, E>(
68
72
 
69
73
  /**
70
74
  * Executes a callback, catching any errors, and returns a result
75
+ *
71
76
  * @param callback Callback to execute
72
77
  * @param error Error value
73
78
  * @returns Callback result
@@ -76,6 +81,7 @@ export function attempt<Value, E>(callback: () => Value, error: E): ExtendedResu
76
81
 
77
82
  /**
78
83
  * Executes a callback, catching any errors, and returns a result
84
+ *
79
85
  * @param callback Callback to execute
80
86
  * @returns Callback result
81
87
  */