@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
@@ -1,6 +1,6 @@
1
1
  //#region src/promise/models.ts
2
2
  /**
3
- * A promise that can be canceled
3
+ * A _Promise_ that can be canceled
4
4
  */
5
5
  var CancelablePromise = class extends Promise {
6
6
  #rejector;
@@ -13,8 +13,9 @@ var CancelablePromise = class extends Promise {
13
13
  this.#rejector = rejector;
14
14
  }
15
15
  /**
16
- * Cancel the promise, rejecting it with an optional reason
17
- * @param reason Optional reason for canceling the promise
16
+ * Cancel the _Promise_, rejecting it with an optional reason
17
+ *
18
+ * @param reason Optional reason for canceling the _Promise_
18
19
  */
19
20
  cancel(reason) {
20
21
  this.#rejector(reason);
@@ -4,17 +4,19 @@ import { PromiseOptions } from "./models.mjs";
4
4
  //#region src/promise/timed.d.ts
5
5
  declare function getTimedPromise<Value>(promise: Promise<Value>, time: number, signal?: AbortSignal): Promise<Value>;
6
6
  /**
7
- * Create a promise that should be settled within a certain amount of time
8
- * @param promise Promise to settle
7
+ * Create a _Promise_ that should be settled within a certain amount of time
8
+ *
9
+ * @param promise _Promise_ to settle
9
10
  * @param options Timed options
10
- * @returns Timed promise
11
+ * @returns Timed _Promise_
11
12
  */
12
13
  declare function timed<Value>(promise: Promise<Value>, options: RequiredKeys<PromiseOptions, 'time'>): Promise<Value>;
13
14
  /**
14
- * Create a promise that should be settled within a certain amount of time
15
- * @param promise Promise to settle
15
+ * Create a _Promise_ that should be settled within a certain amount of time
16
+ *
17
+ * @param promise _Promise_ to settle
16
18
  * @param time How long to wait for _(in milliseconds; defaults to `0`)_
17
- * @returns Timed promise
19
+ * @returns Timed _Promise_
18
20
  */
19
21
  declare function timed<Value>(promise: Promise<Value>, time: number): Promise<Value>;
20
22
  //#endregion
package/dist/query.d.mts CHANGED
@@ -3,12 +3,14 @@ import { PlainObject } from "./models.mjs";
3
3
  //#region src/query.d.ts
4
4
  /**
5
5
  * Convert a query string to a plain _(nested)_ object
6
+ *
6
7
  * @param query Query string to convert
7
8
  * @returns Plain object representation of the query string
8
9
  */
9
10
  declare function fromQuery(query: string): PlainObject;
10
11
  /**
11
12
  * Convert a plain _(nested)_ object to a query string
13
+ *
12
14
  * @param parameters Plain object to convert
13
15
  * @returns Query string representation of the object
14
16
  */
package/dist/query.mjs CHANGED
@@ -5,6 +5,7 @@ import { setValue } from "./internal/value/set.mjs";
5
5
  //#region src/query.ts
6
6
  /**
7
7
  * Convert a query string to a plain _(nested)_ object
8
+ *
8
9
  * @param query Query string to convert
9
10
  * @returns Plain object representation of the query string
10
11
  */
@@ -56,6 +57,7 @@ function setQueryValue(parameters, key, value) {
56
57
  }
57
58
  /**
58
59
  * Convert a plain _(nested)_ object to a query string
60
+ *
59
61
  * @param parameters Plain object to convert
60
62
  * @returns Query string representation of the object
61
63
  */
package/dist/queue.d.mts CHANGED
@@ -7,7 +7,7 @@ import { GenericAsyncCallback, GenericCallback } from "./models.mjs";
7
7
  declare class KeyedQueue<CallbackParameters extends Parameters<GenericAsyncCallback>, CallbackResult> {
8
8
  #private;
9
9
  /**
10
- * Is any queue active?
10
+ * Get keys of all active queues
11
11
  */
12
12
  get active(): string[];
13
13
  /**
@@ -19,11 +19,11 @@ declare class KeyedQueue<CallbackParameters extends Parameters<GenericAsyncCallb
19
19
  */
20
20
  get concurrency(): number;
21
21
  /**
22
- * Are all queues empty?
22
+ * Get keys of all empty queues
23
23
  */
24
24
  get empty(): string[];
25
25
  /**
26
- * Are all queues full?
26
+ * Get keys of all full queues
27
27
  */
28
28
  get full(): string[];
29
29
  /**
@@ -49,6 +49,7 @@ declare class KeyedQueue<CallbackParameters extends Parameters<GenericAsyncCallb
49
49
  constructor(callback: GenericAsyncCallback, options: Required<QueueOptions>);
50
50
  /**
51
51
  * Queue an item for a specific key
52
+ *
52
53
  * @param key Key to queue the item for
53
54
  * @param parameters Parameters to use when item runs
54
55
  * @param signal Optional signal to abort the item
@@ -57,22 +58,26 @@ declare class KeyedQueue<CallbackParameters extends Parameters<GenericAsyncCallb
57
58
  add(key: string, parameters: Tail<CallbackParameters>, signal?: AbortSignal): Queued<CallbackResult>;
58
59
  /**
59
60
  * Clear all items for a specific key _(or all items for all keys, if no key is provided)_
61
+ *
60
62
  * @param key Optional key to clear the queue for
61
63
  */
62
64
  clear(key?: string): void;
63
65
  /**
64
66
  * Get the queue for a specific key
67
+ *
65
68
  * @param key Key to get the queue for
66
69
  * @returns Queue for the key, or `undefined` if it doesn't exist
67
70
  */
68
71
  get(key: string): Queue<Tail<CallbackParameters>, CallbackResult> | undefined;
69
72
  /**
70
73
  * Pause the queue for a specific key _(or all queues, if no key is provided)_
74
+ *
71
75
  * @param key Optional key to pause the queue for
72
76
  */
73
77
  pause(key?: string): void;
74
78
  /**
75
79
  * Remove a specific item for a specific key
80
+ *
76
81
  * @param key Key to remove the item for
77
82
  * @param id ID of the item to remove
78
83
  */
@@ -81,6 +86,7 @@ declare class KeyedQueue<CallbackParameters extends Parameters<GenericAsyncCallb
81
86
  * Remove a queue and its items for a specific key
82
87
  *
83
88
  * _(To remove all items for a specific key, use `clear()` instead)_
89
+ *
84
90
  * @param key Key to remove the queue for
85
91
  */
86
92
  remove(key: string): void;
@@ -90,6 +96,7 @@ declare class KeyedQueue<CallbackParameters extends Parameters<GenericAsyncCallb
90
96
  remove(): void;
91
97
  /**
92
98
  * Resume the queue for a specific key _(or all queues, if no key is provided)_
99
+ *
93
100
  * @param key Optional key to resume the queue for
94
101
  */
95
102
  resume(key?: string): void;
@@ -134,6 +141,7 @@ declare class Queue<CallbackParameters extends Parameters<GenericAsyncCallback>,
134
141
  constructor(callback: GenericAsyncCallback, options: Required<QueueOptions>, key?: string);
135
142
  /**
136
143
  * Add an item to the queue
144
+ *
137
145
  * @param parameters Parameters to use when item runs
138
146
  * @param signal Optional signal to abort the item
139
147
  * @returns Queued item
@@ -152,6 +160,7 @@ declare class Queue<CallbackParameters extends Parameters<GenericAsyncCallback>,
152
160
  pause(): void;
153
161
  /**
154
162
  * Remove and reject a specific item in the queue
163
+ *
155
164
  * @param id ID of queued item
156
165
  */
157
166
  remove(id: number): void;
@@ -207,13 +216,15 @@ type Tail<Values extends any[]> = Values extends [infer _, ...infer Rest] ? Rest
207
216
  declare function keyedQueue<Callback extends GenericAsyncCallback>(callback: Callback, options?: QueueOptions): KeyedQueue<Parameters<Callback>, Awaited<ReturnType<Callback>>>;
208
217
  /**
209
218
  * Create a queue for an asynchronous callback function
219
+ *
210
220
  * @param callback Callback function for queued items
211
221
  * @param options Queue options
212
222
  * @returns Queue instance
213
223
  */
214
224
  declare function queue<Callback extends (key: string, ...parameters: any[]) => Promise<void>>(callback: Callback, options?: QueueOptions): Queue<Parameters<Callback>, Awaited<ReturnType<Callback>>>;
215
225
  /**
216
- * Create a queue for an asynchronous callback function
226
+ * Create a queue for a synchronous callback function
227
+ *
217
228
  * @param callback Callback function for queued items
218
229
  * @param options Queue options
219
230
  * @returns Queue instance
package/dist/queue.mjs CHANGED
@@ -8,7 +8,7 @@ var KeyedQueue = class {
8
8
  #options;
9
9
  #queues = /* @__PURE__ */ new Map();
10
10
  /**
11
- * Is any queue active?
11
+ * Get keys of all active queues
12
12
  */
13
13
  get active() {
14
14
  return this.#getStatus(STATUS_ACTIVE);
@@ -26,13 +26,13 @@ var KeyedQueue = class {
26
26
  return this.#options.concurrency;
27
27
  }
28
28
  /**
29
- * Are all queues empty?
29
+ * Get keys of all empty queues
30
30
  */
31
31
  get empty() {
32
32
  return this.#getStatus(STATUS_EMPTY);
33
33
  }
34
34
  /**
35
- * Are all queues full?
35
+ * Get keys of all full queues
36
36
  */
37
37
  get full() {
38
38
  return this.#getStatus(STATUS_FULL);
@@ -76,6 +76,7 @@ var KeyedQueue = class {
76
76
  }
77
77
  /**
78
78
  * Queue an item for a specific key
79
+ *
79
80
  * @param key Key to queue the item for
80
81
  * @param parameters Parameters to use when item runs
81
82
  * @param signal Optional signal to abort the item
@@ -86,6 +87,7 @@ var KeyedQueue = class {
86
87
  }
87
88
  /**
88
89
  * Clear all items for a specific key _(or all items for all keys, if no key is provided)_
90
+ *
89
91
  * @param key Optional key to clear the queue for
90
92
  */
91
93
  clear(key) {
@@ -93,6 +95,7 @@ var KeyedQueue = class {
93
95
  }
94
96
  /**
95
97
  * Get the queue for a specific key
98
+ *
96
99
  * @param key Key to get the queue for
97
100
  * @returns Queue for the key, or `undefined` if it doesn't exist
98
101
  */
@@ -101,6 +104,7 @@ var KeyedQueue = class {
101
104
  }
102
105
  /**
103
106
  * Pause the queue for a specific key _(or all queues, if no key is provided)_
107
+ *
104
108
  * @param key Optional key to pause the queue for
105
109
  */
106
110
  pause(key) {
@@ -123,6 +127,7 @@ var KeyedQueue = class {
123
127
  }
124
128
  /**
125
129
  * Resume the queue for a specific key _(or all queues, if no key is provided)_
130
+ *
126
131
  * @param key Optional key to resume the queue for
127
132
  */
128
133
  resume(key) {
@@ -220,6 +225,7 @@ var Queue = class {
220
225
  }
221
226
  /**
222
227
  * Add an item to the queue
228
+ *
223
229
  * @param parameters Parameters to use when item runs
224
230
  * @param signal Optional signal to abort the item
225
231
  * @returns Queued item
@@ -276,6 +282,7 @@ var Queue = class {
276
282
  }
277
283
  /**
278
284
  * Remove and reject a specific item in the queue
285
+ *
279
286
  * @param id ID of queued item
280
287
  */
281
288
  remove(id) {
package/dist/random.d.mts CHANGED
@@ -1,13 +1,15 @@
1
- import { getRandomFloat, getRandomInteger } from "./internal/random.mjs";
1
+ import { getRandomFloatingNumber, getRandomInteger } from "./internal/random.mjs";
2
2
 
3
3
  //#region src/random.d.ts
4
4
  /**
5
5
  * Get a random boolean
6
+ *
6
7
  * @returns Random boolean
7
8
  */
8
9
  declare function getRandomBoolean(): boolean;
9
10
  /**
10
11
  * Get a random string of characters with a specified length
12
+ *
11
13
  * @param length Length of random string
12
14
  * @param selection String of characters to select from _(defaults to lowercase English alphabet)_
13
15
  * @returns Random string of characters
@@ -15,23 +17,27 @@ declare function getRandomBoolean(): boolean;
15
17
  declare function getRandomCharacters(length: number, selection?: string): string;
16
18
  /**
17
19
  * Get a random hexadecimal color
20
+ *
18
21
  * @param prefix Prefix the color with `#`? _(defaults to `false`)_
19
22
  * @returns Random hexadecimal color string in the format `(#)RRGGBB`
20
23
  */
21
24
  declare function getRandomColor(prefix?: boolean): string;
22
25
  /**
23
26
  * Get a random hexadecimal character
27
+ *
24
28
  * @returns Random hexadecimal character from `0-9` and `A-F`
25
29
  */
26
30
  declare function getRandomHex(): string;
27
31
  /**
28
32
  * Get a random item from an array
33
+ *
29
34
  * @param array Array to get a random item from
30
35
  * @returns Random item from the array, or `undefined` if unable to retrieve one
31
36
  */
32
37
  declare function getRandomItem<Value>(array: Value[]): Value | undefined;
33
38
  /**
34
39
  * Get an amount of random items from an array
40
+ *
35
41
  * @param array Array to get random items from
36
42
  * @param amount Amount of items to return
37
43
  * @returns Array of random items
@@ -39,9 +45,10 @@ declare function getRandomItem<Value>(array: Value[]): Value | undefined;
39
45
  declare function getRandomItems<Value>(array: Value[], amount: number): Value[];
40
46
  /**
41
47
  * Get a shuffled array
48
+ *
42
49
  * @param array Array to get random items from
43
50
  * @returns Shuffled version of the original array
44
51
  */
45
52
  declare function getRandomItems<Value>(array: Value[]): Value[];
46
53
  //#endregion
47
- export { getRandomBoolean, getRandomCharacters, getRandomColor, getRandomFloat, getRandomHex, getRandomInteger, getRandomItem, getRandomItems };
54
+ export { getRandomBoolean, getRandomCharacters, getRandomColor, getRandomFloatingNumber as getRandomFloat, getRandomHex, getRandomInteger, getRandomItem, getRandomItems };
package/dist/random.mjs CHANGED
@@ -1,9 +1,10 @@
1
- import { getRandomFloat, getRandomInteger } from "./internal/random.mjs";
1
+ import { getRandomFloatingNumber, getRandomInteger } from "./internal/random.mjs";
2
2
  import { shuffle } from "./internal/array/shuffle.mjs";
3
3
  import { join } from "./internal/string.mjs";
4
4
  //#region src/random.ts
5
5
  /**
6
6
  * Get a random boolean
7
+ *
7
8
  * @returns Random boolean
8
9
  */
9
10
  function getRandomBoolean() {
@@ -11,6 +12,7 @@ function getRandomBoolean() {
11
12
  }
12
13
  /**
13
14
  * Get a random string of characters with a specified length
15
+ *
14
16
  * @param length Length of random string
15
17
  * @param selection String of characters to select from _(defaults to lowercase English alphabet)_
16
18
  * @returns Random string of characters
@@ -24,6 +26,7 @@ function getRandomCharacters(length, selection) {
24
26
  }
25
27
  /**
26
28
  * Get a random hexadecimal color
29
+ *
27
30
  * @param prefix Prefix the color with `#`? _(defaults to `false`)_
28
31
  * @returns Random hexadecimal color string in the format `(#)RRGGBB`
29
32
  */
@@ -32,6 +35,7 @@ function getRandomColor(prefix) {
32
35
  }
33
36
  /**
34
37
  * Get a random hexadecimal character
38
+ *
35
39
  * @returns Random hexadecimal character from `0-9` and `A-F`
36
40
  */
37
41
  function getRandomHex() {
@@ -39,6 +43,7 @@ function getRandomHex() {
39
43
  }
40
44
  /**
41
45
  * Get a random item from an array
46
+ *
42
47
  * @param array Array to get a random item from
43
48
  * @returns Random item from the array, or `undefined` if unable to retrieve one
44
49
  */
@@ -57,4 +62,4 @@ const BOOLEAN_MODIFIER = .5;
57
62
  const HEX_CHARACTERS = "0123456789ABCDEF";
58
63
  const HEX_MAXIMUM = 15;
59
64
  //#endregion
60
- export { getRandomBoolean, getRandomCharacters, getRandomColor, getRandomFloat, getRandomHex, getRandomInteger, getRandomItem, getRandomItems };
65
+ export { getRandomBoolean, getRandomCharacters, getRandomColor, getRandomFloatingNumber as getRandomFloat, getRandomHex, getRandomInteger, getRandomItem, getRandomItems };
@@ -2,10 +2,11 @@ import { ExtendedResult, Result } from "./models.mjs";
2
2
 
3
3
  //#region src/result/index.d.ts
4
4
  /**
5
- * Executes a promise, catching any errors, and returns a result
5
+ * Executes a _Promise_, catching any errors, and returns a result
6
6
  *
7
- * Available as `asyncAttempt` and `attempt.async`
8
- * @param promise Promise to execute
7
+ * _Available as `asyncAttempt` and `attempt.async`_
8
+ *
9
+ * @param promise _Promise_ to execute
9
10
  * @param error Error value
10
11
  * @returns Callback result
11
12
  */
@@ -13,30 +14,34 @@ declare function asyncAttempt<Value, E>(promise: Promise<Value>, error: E): Prom
13
14
  /**
14
15
  * Executes a callback asynchronously, catching any errors, and returns a result
15
16
  *
16
- * Available as `asyncAttempt` and `attempt.async`
17
+ * _Available as `asyncAttempt` and `attempt.async`_
18
+ *
17
19
  * @param callback Callback to execute
18
20
  * @param error Error value
19
21
  * @returns Callback result
20
22
  */
21
23
  declare function asyncAttempt<Value, E>(callback: () => Promise<Value>, error: E): Promise<ExtendedResult<Awaited<Value>, E>>;
22
24
  /**
23
- * Executes a promise, catching any errors, and returns a result
25
+ * Executes a _Promise_, catching any errors, and returns a result
26
+ *
27
+ * _Available as `asyncAttempt` and `attempt.async`_
24
28
  *
25
- * Available as `asyncAttempt` and `attempt.async`
26
- * @param promise Promise to execute
29
+ * @param promise _Promise_ to execute
27
30
  * @returns Callback result
28
31
  */
29
32
  declare function asyncAttempt<Value>(promise: Promise<Value>): Promise<Result<Awaited<Value>>>;
30
33
  /**
31
34
  * Executes a callback asynchronously, catching any errors, and returns a result
32
35
  *
33
- * Available as `asyncAttempt` and `attempt.async`
36
+ * _Available as `asyncAttempt` and `attempt.async`_
37
+ *
34
38
  * @param callback Callback to execute
35
39
  * @returns Callback result
36
40
  */
37
41
  declare function asyncAttempt<Value>(callback: () => Promise<Value>): Promise<Result<Awaited<Value>>>;
38
42
  /**
39
43
  * Executes a callback, catching any errors, and returns a result
44
+ *
40
45
  * @param callback Callback to execute
41
46
  * @param error Error value
42
47
  * @returns Callback result
@@ -44,6 +49,7 @@ declare function asyncAttempt<Value>(callback: () => Promise<Value>): Promise<Re
44
49
  declare function attempt<Value, E>(callback: () => Value, error: E): ExtendedResult<Value, E>;
45
50
  /**
46
51
  * Executes a callback, catching any errors, and returns a result
52
+ *
47
53
  * @param callback Callback to execute
48
54
  * @returns Callback result
49
55
  */
@@ -2,33 +2,41 @@ import { AnyResult, ResultMatch } from "./models.mjs";
2
2
 
3
3
  //#region src/result/match.d.ts
4
4
  /**
5
- * Handles a result with match callbacks
5
+ * Handles a _Result_ with match callbacks
6
6
  *
7
- * Available as `asyncMatchResult` and `matchResult.async`
8
- * @param result Result to handle
7
+ * _Available as `asyncMatchResult` and `matchResult.async`_
8
+ *
9
+ * @param result _Result_ to handle
9
10
  * @param handler Match callbacks
11
+ * @returns Matched value-_Promise_
10
12
  */
11
13
  declare function asyncMatchResult<Value, Returned, E = Error>(result: AnyResult<Value, E> | Promise<AnyResult<Value, E>> | (() => Promise<AnyResult<Value, E>>), handler: ResultMatch<Value, Returned, E>): Promise<Returned>;
12
14
  /**
13
- * Handles a result with match callbacks
15
+ * Handles a _Result_ with match callbacks
16
+ *
17
+ * _Available as `asyncMatchResult` and `matchResult.async`_
14
18
  *
15
- * Available as `asyncMatchResult` and `matchResult.async`
16
- * @param result Result to handle
19
+ * @param result _Result_ to handle
17
20
  * @param ok Ok callback
18
21
  * @param error Error callback
22
+ * @returns Matched value-_Promise_
19
23
  */
20
24
  declare function asyncMatchResult<Value, Returned, E = Error>(result: AnyResult<Value, E> | Promise<AnyResult<Value, E>> | (() => Promise<AnyResult<Value, E>>), ok: ResultMatch<Value, Returned, E>['ok'], error: ResultMatch<Value, Returned, E>['error']): Promise<Returned>;
21
25
  /**
22
- * Handles a result with match callbacks
23
- * @param result Result to handle
26
+ * Handles a _Result_ with match callbacks
27
+ *
28
+ * @param result _Result_ to handle
24
29
  * @param handler Match callbacks
30
+ * @returns Matched value
25
31
  */
26
32
  declare function matchResult<Value, Returned, E = Error>(result: AnyResult<Value, E> | (() => AnyResult<Value, E>), handler: ResultMatch<Value, Returned, E>): Returned;
27
33
  /**
28
- * Handles a result with match callbacks
29
- * @param result Result to handle
34
+ * Handles a _Result_ with match callbacks
35
+ *
36
+ * @param result _Result_ to handle
30
37
  * @param ok Ok callback
31
38
  * @param error Error callback
39
+ * @returns Matched value
32
40
  */
33
41
  declare function matchResult<Value, Returned, E = Error>(result: AnyResult<Value, E> | (() => AnyResult<Value, E>), ok: ResultMatch<Value, Returned, E>['ok'], error: ResultMatch<Value, Returned, E>['error']): Returned;
34
42
  declare namespace matchResult {
@@ -4,6 +4,7 @@ import { isError, isOk, isResult } from "../internal/result.mjs";
4
4
  //#region src/result/misc.d.ts
5
5
  /**
6
6
  * Creates an extended error result
7
+ *
7
8
  * @param value Error value
8
9
  * @param original Original error
9
10
  * @returns Error result
@@ -11,6 +12,7 @@ import { isError, isOk, isResult } from "../internal/result.mjs";
11
12
  declare function error<E>(value: E, original: Error): ExtendedErr<E>;
12
13
  /**
13
14
  * Creates an error result
15
+ *
14
16
  * @param value Error value
15
17
  * @returns Error result
16
18
  */
@@ -18,38 +20,43 @@ declare function error<E>(value: E): Err<E>;
18
20
  declare function getError<E>(value: E, original?: Error): Err<E> | ExtendedErr<E>;
19
21
  /**
20
22
  * Creates an ok result
23
+ *
21
24
  * @param value Value
22
25
  * @returns Ok result
23
26
  */
24
27
  declare function ok<Value>(value: Value): Ok<Value>;
25
28
  /**
26
- * Converts a result to a promise
29
+ * Converts a result to a _Promise_
27
30
  *
28
31
  * Resolves if ok, rejects for error
32
+ *
29
33
  * @param callback Callback to get the result
30
34
  * @returns Promised result
31
35
  */
32
36
  declare function toPromise<Value, E = Error>(callback: () => AnyResult<Value, E>): Promise<Value>;
33
37
  /**
34
- * Converts a result to a promise
38
+ * Converts a result to a _Promise_
35
39
  *
36
40
  * Resolves if ok, rejects for error
37
- * @param result Result to convert
41
+ *
42
+ * @param result _Result_ to convert
38
43
  * @returns Promised result
39
44
  */
40
45
  declare function toPromise<Value, E = Error>(result: AnyResult<Value, E>): Promise<Value>;
41
46
  /**
42
47
  * Gets the value of an ok result _(or a default value)_
43
- * @param value Result to unwrap
48
+ *
49
+ * @param value _Result_ to unwrap
44
50
  * @param defaultValue Default value
45
- * @returns Value of the result _(or the default value)_
51
+ * @returns Value of the _Result_ _(or the default value)_
46
52
  */
47
53
  declare function unwrap<Value, E = Error>(value: Result<Value, E>, defaultValue: Value): Value;
48
54
  /**
49
55
  * Gets the value of an ok result _(or a default value)_
50
- * @param value Result to unwrap
56
+ *
57
+ * @param value _Result_ to unwrap
51
58
  * @param defaultValue Default value
52
- * @returns Value of the result _(or the default value)_
59
+ * @returns Value of the _Result_ _(or the default value)_
53
60
  */
54
61
  declare function unwrap(value: unknown, defaultValue: unknown): unknown;
55
62
  //#endregion
@@ -13,6 +13,7 @@ function getError(value, original) {
13
13
  }
14
14
  /**
15
15
  * Creates an ok result
16
+ *
16
17
  * @param value Value
17
18
  * @returns Ok result
18
19
  */
@@ -23,10 +24,11 @@ function ok(value) {
23
24
  };
24
25
  }
25
26
  /**
26
- * Converts a result to a promise
27
+ * Converts a _Result_ to a _Promise_
27
28
  *
28
29
  * Resolves if ok, rejects for error
29
- * @param result Result to convert
30
+ *
31
+ * @param result _Result_ to convert
30
32
  * @returns Promised result
31
33
  */
32
34
  async function toPromise(result) {
@@ -39,6 +39,7 @@ type Result<Value, E = Error> = Err<E> | Ok<Value>;
39
39
  type ResultMatch<Value, Returned, E = Error> = {
40
40
  /**
41
41
  * Callback for error result
42
+ *
42
43
  * @param error Error value
43
44
  * @param original Original error, if available
44
45
  * @returns Value to return
@@ -46,6 +47,7 @@ type ResultMatch<Value, Returned, E = Error> = {
46
47
  error: (error: E, original?: Error) => Returned;
47
48
  /**
48
49
  * Callback for ok result
50
+ *
49
51
  * @param value Ok value
50
52
  * @returns Value to return
51
53
  */