@oscarpalmer/atoms 0.186.2 → 0.187.1

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 (230) 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 +703 -342
  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/internal/value/set.mjs +1 -1
  76. package/dist/is.d.mts +12 -0
  77. package/dist/is.mjs +16 -1
  78. package/dist/logger.d.mts +7 -6
  79. package/dist/logger.mjs +6 -5
  80. package/dist/math.d.mts +36 -18
  81. package/dist/math.mjs +6 -3
  82. package/dist/models.d.mts +3 -3
  83. package/dist/promise/delay.d.mts +2 -0
  84. package/dist/promise/helpers.d.mts +6 -4
  85. package/dist/promise/helpers.mjs +6 -4
  86. package/dist/promise/index.d.mts +49 -38
  87. package/dist/promise/misc.d.mts +10 -7
  88. package/dist/promise/misc.mjs +4 -3
  89. package/dist/promise/models.d.mts +18 -19
  90. package/dist/promise/models.mjs +4 -3
  91. package/dist/promise/timed.d.mts +8 -6
  92. package/dist/query.d.mts +2 -0
  93. package/dist/query.mjs +27 -17
  94. package/dist/queue.d.mts +15 -4
  95. package/dist/queue.mjs +10 -3
  96. package/dist/random.d.mts +9 -2
  97. package/dist/random.mjs +7 -2
  98. package/dist/result/index.d.mts +14 -8
  99. package/dist/result/match.d.mts +18 -10
  100. package/dist/result/misc.d.mts +14 -7
  101. package/dist/result/misc.mjs +4 -2
  102. package/dist/result/models.d.mts +2 -0
  103. package/dist/result/work/flow.d.mts +86 -62
  104. package/dist/result/work/pipe.d.mts +55 -33
  105. package/dist/sized/map.d.mts +19 -16
  106. package/dist/sized/map.mjs +4 -4
  107. package/dist/sized/set.d.mts +20 -16
  108. package/dist/sized/set.mjs +8 -7
  109. package/dist/string/case.d.mts +8 -0
  110. package/dist/string/case.mjs +8 -0
  111. package/dist/string/fuzzy.d.mts +19 -5
  112. package/dist/string/fuzzy.mjs +7 -0
  113. package/dist/string/index.d.mts +17 -2
  114. package/dist/string/index.mjs +7 -9
  115. package/dist/string/match.d.mts +3 -0
  116. package/dist/string/match.mjs +3 -0
  117. package/dist/string/normalize.d.mts +6 -2
  118. package/dist/string/normalize.mjs +5 -2
  119. package/dist/string/template.d.mts +38 -9
  120. package/dist/string/template.mjs +19 -19
  121. package/dist/value/clone.d.mts +25 -4
  122. package/dist/value/clone.mjs +36 -22
  123. package/dist/value/collection.d.mts +9 -6
  124. package/dist/value/collection.mjs +3 -2
  125. package/dist/value/diff.d.mts +3 -1
  126. package/dist/value/diff.mjs +1 -0
  127. package/dist/value/freeze.d.mts +118 -9
  128. package/dist/value/freeze.mjs +56 -14
  129. package/dist/value/index.d.mts +1 -2
  130. package/dist/value/index.mjs +1 -2
  131. package/dist/value/merge.d.mts +11 -5
  132. package/dist/value/merge.mjs +2 -2
  133. package/dist/value/omit.d.mts +1 -0
  134. package/dist/value/omit.mjs +1 -0
  135. package/dist/value/pick.d.mts +1 -0
  136. package/dist/value/pick.mjs +1 -0
  137. package/dist/value/shake.d.mts +1 -0
  138. package/dist/value/shake.mjs +1 -0
  139. package/dist/value/smush.d.mts +1 -0
  140. package/dist/value/smush.mjs +1 -0
  141. package/dist/value/transform.d.mts +7 -3
  142. package/dist/value/unsmush.d.mts +1 -0
  143. package/dist/value/unsmush.mjs +1 -0
  144. package/package.json +12 -8
  145. package/src/array/filter.ts +4 -4
  146. package/src/array/find.ts +4 -4
  147. package/src/array/first.ts +4 -4
  148. package/src/array/get.ts +40 -5
  149. package/src/array/group-by.ts +6 -6
  150. package/src/array/last.ts +4 -4
  151. package/src/array/match.ts +7 -6
  152. package/src/array/move.ts +7 -7
  153. package/src/array/select.ts +1 -0
  154. package/src/array/slice.ts +3 -3
  155. package/src/array/sort.ts +15 -10
  156. package/src/array/swap.ts +1 -1
  157. package/src/array/to-map.ts +32 -32
  158. package/src/array/to-record.ts +6 -6
  159. package/src/array/to-set.ts +6 -6
  160. package/src/beacon.ts +6 -0
  161. package/src/color/index.ts +6 -2
  162. package/src/color/instance.ts +78 -14
  163. package/src/color/misc/get.ts +39 -11
  164. package/src/color/misc/is.ts +26 -11
  165. package/src/color/misc/state.ts +1 -1
  166. package/src/color/models.ts +7 -4
  167. package/src/color/space/hex.ts +15 -6
  168. package/src/color/space/hsl.ts +10 -4
  169. package/src/color/space/rgb.ts +21 -12
  170. package/src/function/assert.ts +20 -14
  171. package/src/function/limit.ts +8 -6
  172. package/src/function/memoize.ts +24 -5
  173. package/src/function/once.ts +5 -3
  174. package/src/function/retry.ts +7 -3
  175. package/src/function/work.ts +146 -98
  176. package/src/{kalas.ts → herald.ts} +23 -14
  177. package/src/index.ts +3 -2
  178. package/src/internal/array/index-of.ts +4 -4
  179. package/src/internal/array/insert.ts +1 -1
  180. package/src/internal/array/shuffle.ts +2 -1
  181. package/src/internal/is.ts +26 -8
  182. package/src/internal/math/aggregate.ts +9 -9
  183. package/src/internal/number.ts +13 -2
  184. package/src/internal/random.ts +10 -4
  185. package/src/internal/result.ts +30 -29
  186. package/src/internal/string.ts +28 -0
  187. package/src/internal/value/compare.ts +5 -2
  188. package/src/internal/value/equal.ts +13 -4
  189. package/src/internal/value/get.ts +17 -17
  190. package/src/internal/value/has.ts +54 -11
  191. package/src/internal/value/set.ts +25 -1
  192. package/src/is.ts +15 -1
  193. package/src/logger.ts +8 -7
  194. package/src/math.ts +36 -18
  195. package/src/models.ts +3 -3
  196. package/src/promise/delay.ts +2 -0
  197. package/src/promise/helpers.ts +6 -4
  198. package/src/promise/index.ts +49 -38
  199. package/src/promise/misc.ts +10 -7
  200. package/src/promise/models.ts +18 -19
  201. package/src/promise/timed.ts +8 -6
  202. package/src/query.ts +39 -28
  203. package/src/queue.ts +15 -4
  204. package/src/random.ts +8 -1
  205. package/src/result/index.ts +14 -8
  206. package/src/result/match.ts +18 -10
  207. package/src/result/misc.ts +17 -9
  208. package/src/result/models.ts +2 -0
  209. package/src/result/work/flow.ts +86 -62
  210. package/src/result/work/pipe.ts +55 -33
  211. package/src/sized/map.ts +20 -17
  212. package/src/sized/set.ts +21 -17
  213. package/src/string/case.ts +8 -0
  214. package/src/string/fuzzy.ts +19 -5
  215. package/src/string/index.ts +18 -15
  216. package/src/string/match.ts +3 -0
  217. package/src/string/normalize.ts +6 -2
  218. package/src/string/template.ts +69 -18
  219. package/src/value/clone.ts +51 -26
  220. package/src/value/collection.ts +9 -6
  221. package/src/value/diff.ts +3 -1
  222. package/src/value/freeze.ts +239 -25
  223. package/src/value/index.ts +0 -1
  224. package/src/value/merge.ts +11 -5
  225. package/src/value/omit.ts +1 -0
  226. package/src/value/pick.ts +1 -0
  227. package/src/value/shake.ts +1 -0
  228. package/src/value/smush.ts +1 -0
  229. package/src/value/transform.ts +7 -3
  230. package/src/value/unsmush.ts +1 -0
@@ -40,14 +40,14 @@ function getMapValues(
40
40
  }
41
41
 
42
42
  /**
43
- * Create a Map from an array of items using callbacks
43
+ * Create a _Map_ from an array of items using callbacks
44
44
  *
45
45
  * If multiple items have the same key, the latest item's value will be used
46
46
  *
47
47
  * @param array Array to convert
48
48
  * @param key Callback to get an item's grouping key
49
49
  * @param value Callback to get an item's value
50
- * @returns Map of keyed values
50
+ * @returns _Map_ of keyed values
51
51
  *
52
52
  * @example
53
53
  * ```typescript
@@ -69,14 +69,14 @@ export function toMap<
69
69
  ): Map<ReturnType<KeyCallback>, ReturnType<ValueCallback>>;
70
70
 
71
71
  /**
72
- * Create a Map from an array of items using a callback and value
72
+ * Create a _Map_ from an array of items using a callback and value
73
73
  *
74
74
  * If multiple items have the same key, the latest item's value will be used
75
75
  *
76
76
  * @param array Array to convert
77
77
  * @param key Callback to get an item's grouping key
78
78
  * @param value Key to use for value
79
- * @returns Map of keyed values
79
+ * @returns _Map_ of keyed values
80
80
  *
81
81
  * @example
82
82
  * ```typescript
@@ -94,14 +94,14 @@ export function toMap<
94
94
  >(array: Item[], key: KeyCallback, value: ItemValue): Map<ReturnType<KeyCallback>, Item[ItemValue]>;
95
95
 
96
96
  /**
97
- * Create a Map from an array of items using a key and callback
97
+ * Create a _Map_ from an array of items using a key and callback
98
98
  *
99
99
  * If multiple items have the same key, the latest item's value will be used
100
100
  *
101
101
  * @param array Array to convert
102
102
  * @param key Key to use for grouping
103
103
  * @param value Callback to get an item's value
104
- * @returns Map of keyed values
104
+ * @returns _Map_ of keyed values
105
105
  *
106
106
  * @example
107
107
  * ```typescript
@@ -119,14 +119,14 @@ export function toMap<
119
119
  >(array: Item[], key: ItemKey, value: ValueCallback): Map<Item[ItemKey], ReturnType<ValueCallback>>;
120
120
 
121
121
  /**
122
- * Create a Map from an array of items using a key and value
122
+ * Create a _Map_ from an array of items using a key and value
123
123
  *
124
124
  * If multiple items have the same key, the latest item's value will be used
125
125
  *
126
126
  * @param array Array to convert
127
127
  * @param key Key to use for grouping
128
128
  * @param value Key to use for value
129
- * @returns Map of keyed values
129
+ * @returns _Map_ of keyed values
130
130
  *
131
131
  * @example
132
132
  * ```typescript
@@ -144,13 +144,13 @@ export function toMap<
144
144
  >(array: Item[], key: ItemKey, value: ItemValue): Map<Item[ItemKey], Item[ItemValue]>;
145
145
 
146
146
  /**
147
- * Create a Map from an array of items using a callback
147
+ * Create a _Map_ from an array of items using a callback
148
148
  *
149
149
  * If multiple items have the same key, the latest item will be used
150
150
  *
151
151
  * @param array Array to convert
152
152
  * @param callback Callback to get an item's grouping key
153
- * @returns Map of keyed items
153
+ * @returns _Map_ of keyed items
154
154
  *
155
155
  * @example
156
156
  * ```typescript
@@ -166,13 +166,13 @@ export function toMap<Item, Callback extends (item: Item, index: number, array:
166
166
  ): Map<ReturnType<Callback>, Item>;
167
167
 
168
168
  /**
169
- * Create a Map from an array of items using a key
169
+ * Create a _Map_ from an array of items using a key
170
170
  *
171
171
  * If multiple items have the same key, the latest item will be used
172
172
  *
173
173
  * @param array Array to convert
174
174
  * @param key Key to use for grouping
175
- * @returns Map of keyed items
175
+ * @returns _Map_ of keyed items
176
176
  *
177
177
  * @example
178
178
  * ```typescript
@@ -188,10 +188,10 @@ export function toMap<Item extends PlainObject, ItemKey extends keyof Item>(
188
188
  ): Map<Item[ItemKey], Item>;
189
189
 
190
190
  /**
191
- * Create a Map from an array of items _(using indices as keys)_
191
+ * Create a _Map_ from an array of items _(using indices as keys)_
192
192
  *
193
193
  * @param array Array to convert
194
- * @returns Map of indiced items
194
+ * @returns _Map_ of indiced items
195
195
  *
196
196
  * @example
197
197
  * ```typescript
@@ -209,14 +209,14 @@ export function toMap(array: unknown[], first?: unknown, second?: unknown): unkn
209
209
  toMap.arrays = toMapArrays;
210
210
 
211
211
  /**
212
- * Create a Map from an array of items using callbacks, grouping values into arrays
212
+ * Create a _Map_ from an array of items using callbacks, grouping values into arrays
213
213
  *
214
- * Available as `toMapArrays` and `toMap.arrays`
214
+ * _Available as `toMapArrays` and `toMap.arrays`_
215
215
  *
216
216
  * @param array Array to convert
217
217
  * @param key Callback to get an item's grouping key
218
218
  * @param value Callback to get an item's value
219
- * @returns Map of keyed arrays of values
219
+ * @returns _Map_ of keyed arrays of values
220
220
  *
221
221
  * @example
222
222
  * ```typescript
@@ -238,14 +238,14 @@ export function toMapArrays<
238
238
  ): Map<ReturnType<KeyCallback>, ReturnType<ValueCallback>[]>;
239
239
 
240
240
  /**
241
- * Create a Map from an array of items using a callback and value, grouping values into arrays
241
+ * Create a _Map_ from an array of items using a callback and value, grouping values into arrays
242
242
  *
243
- * Available as `toMapArrays` and `toMap.arrays`
243
+ * _Available as `toMapArrays` and `toMap.arrays`_
244
244
  *
245
245
  * @param array Array to convert
246
246
  * @param key Callback to get an item's grouping key
247
247
  * @param value Key to use for value
248
- * @returns Map of keyed arrays of values
248
+ * @returns _Map_ of keyed arrays of values
249
249
  *
250
250
  * @example
251
251
  * ```typescript
@@ -267,14 +267,14 @@ export function toMapArrays<
267
267
  ): Map<ReturnType<KeyCallback>, Item[ItemValue][]>;
268
268
 
269
269
  /**
270
- * Create a Map from an array of items using a key and callback, grouping values into arrays
270
+ * Create a _Map_ from an array of items using a key and callback, grouping values into arrays
271
271
  *
272
- * Available as `toMapArrays` and `toMap.arrays`
272
+ * _Available as `toMapArrays` and `toMap.arrays`_
273
273
  *
274
274
  * @param array Array to convert
275
275
  * @param key Key to use for grouping
276
276
  * @param value Callback to get an item's value
277
- * @returns Map of keyed arrays of values
277
+ * @returns _Map_ of keyed arrays of values
278
278
  *
279
279
  * @example
280
280
  * ```typescript
@@ -296,14 +296,14 @@ export function toMapArrays<
296
296
  ): Map<Item[ItemKey], ReturnType<ValueCallback>[]>;
297
297
 
298
298
  /**
299
- * Create a Map from an array of items using a key and value, grouping values into arrays
299
+ * Create a _Map_ from an array of items using a key and value, grouping values into arrays
300
300
  *
301
- * Available as `toMapArrays` and `toMap.arrays`
301
+ * _Available as `toMapArrays` and `toMap.arrays`_
302
302
  *
303
303
  * @param array Array to convert
304
304
  * @param key Key to use for grouping
305
305
  * @param value Key to use for value
306
- * @returns Map of keyed arrays of values
306
+ * @returns _Map_ of keyed arrays of values
307
307
  *
308
308
  * @example
309
309
  * ```typescript
@@ -321,13 +321,13 @@ export function toMapArrays<
321
321
  >(array: Item[], key: ItemKey, value: ItemValue): Map<Item[ItemKey], Item[ItemValue][]>;
322
322
 
323
323
  /**
324
- * Create a Map from an array of items using a callback, grouping items into arrays
324
+ * Create a _Map_ from an array of items using a callback, grouping items into arrays
325
325
  *
326
- * Available as `toMapArrays` and `toMap.arrays`
326
+ * _Available as `toMapArrays` and `toMap.arrays`_
327
327
  *
328
328
  * @param array Array to convert
329
329
  * @param callback Callback to get an item's grouping key
330
- * @returns Map of keyed arrays of items
330
+ * @returns _Map_ of keyed arrays of items
331
331
  *
332
332
  * @example
333
333
  * ```typescript
@@ -343,13 +343,13 @@ export function toMapArrays<
343
343
  >(array: Item[], callback: Callback): Map<ReturnType<Callback>, Item[]>;
344
344
 
345
345
  /**
346
- * Create a Map from an array of items using a key, grouping items into arrays
346
+ * Create a _Map_ from an array of items using a key, grouping items into arrays
347
347
  *
348
- * Available as `toMapArrays` and `toMap.arrays`
348
+ * _Available as `toMapArrays` and `toMap.arrays`_
349
349
  *
350
350
  * @param array Array to convert
351
351
  * @param key Key to use for grouping
352
- * @returns Map of keyed arrays of items
352
+ * @returns _Map_ of keyed arrays of items
353
353
  *
354
354
  * @example
355
355
  * ```typescript
@@ -187,7 +187,7 @@ toRecord.arrays = toRecordArrays;
187
187
  /**
188
188
  * Create a record from an array of items using callbacks, grouping values into arrays
189
189
  *
190
- * Available as `toRecordArrays` and `toRecord.arrays`
190
+ * _Available as `toRecordArrays` and `toRecord.arrays`_
191
191
  *
192
192
  * @param array Array to convert
193
193
  * @param key Callback to get an item's grouping key
@@ -216,7 +216,7 @@ export function toRecordArrays<
216
216
  /**
217
217
  * Create a record from an array of items using a callback and value, grouping values into arrays
218
218
  *
219
- * Available as `toRecordArrays` and `toRecord.arrays`
219
+ * _Available as `toRecordArrays` and `toRecord.arrays`_
220
220
  *
221
221
  * @param array Array to convert
222
222
  * @param callback Callback to get an item's grouping key
@@ -245,7 +245,7 @@ export function toRecordArrays<
245
245
  /**
246
246
  * Create a record from an array of items using a key and callback, grouping values into arrays
247
247
  *
248
- * Available as `toRecordArrays` and `toRecord.arrays`
248
+ * _Available as `toRecordArrays` and `toRecord.arrays`_
249
249
  *
250
250
  * @param array Array to convert
251
251
  * @param key Key to use for grouping
@@ -274,7 +274,7 @@ export function toRecordArrays<
274
274
  /**
275
275
  * Create a record from an array of items using a key and value, grouping values into arrays
276
276
  *
277
- * Available as `toRecordArrays` and `toRecord.arrays`
277
+ * _Available as `toRecordArrays` and `toRecord.arrays`_
278
278
  *
279
279
  * @param array Array to convert
280
280
  * @param key Key to use for grouping
@@ -303,7 +303,7 @@ export function toRecordArrays<
303
303
  /**
304
304
  * Create a record from an array of items using a callback, grouping items into arrays
305
305
  *
306
- * Available as `toRecordArrays` and `toRecord.arrays`
306
+ * _Available as `toRecordArrays` and `toRecord.arrays`_
307
307
  *
308
308
  * @param array Array to convert
309
309
  * @param callback Callback to get an item's grouping key
@@ -325,7 +325,7 @@ export function toRecordArrays<
325
325
  /**
326
326
  * Create a record from an array of items using a key, grouping items into arrays
327
327
  *
328
- * Available as `toRecordArrays` and `toRecord.arrays`
328
+ * _Available as `toRecordArrays` and `toRecord.arrays`_
329
329
  *
330
330
  * @param array Array to convert
331
331
  * @param key Key to use for grouping
@@ -4,11 +4,11 @@ import type {PlainObject} from '../models';
4
4
  // #region Functions
5
5
 
6
6
  /**
7
- * Create a Set from an array of items using a callback
7
+ * Create a _Set_ from an array of items using a callback
8
8
  *
9
9
  * @param array Array to convert
10
10
  * @param callback Callback to get an item's value
11
- * @returns Set of values
11
+ * @returns _Set_ of values
12
12
  *
13
13
  * @example
14
14
  * ```typescript
@@ -24,11 +24,11 @@ export function toSet<Item, Callback extends (item: Item, index: number, array:
24
24
  ): Set<ReturnType<Callback>>;
25
25
 
26
26
  /**
27
- * Create a Set from an array of items using a key
27
+ * Create a _Set_ from an array of items using a key
28
28
  *
29
29
  * @param array Array to convert
30
30
  * @param key Key to use for value
31
- * @returns Set of values
31
+ * @returns _Set_ of values
32
32
  *
33
33
  * @example
34
34
  * ```typescript
@@ -44,10 +44,10 @@ export function toSet<Item extends PlainObject, ItemKey extends keyof Item>(
44
44
  ): Set<Item[ItemKey]>;
45
45
 
46
46
  /**
47
- * Create a Set from an array of items
47
+ * Create a _Set_ from an array of items
48
48
  *
49
49
  * @param array Array to convert
50
- * @returns Set of items
50
+ * @returns _Set_ of items
51
51
  *
52
52
  * @example
53
53
  * ```typescript
package/src/beacon.ts CHANGED
@@ -58,6 +58,7 @@ class Beacon<Value> {
58
58
 
59
59
  /**
60
60
  * Emit a new value
61
+ *
61
62
  * @param value Value to set and emit
62
63
  * @param finish Finish the beacon after emitting? _(defaults to `false`)_
63
64
  */
@@ -67,6 +68,7 @@ class Beacon<Value> {
67
68
 
68
69
  /**
69
70
  * Emit an error
71
+ *
70
72
  * @param value Error to emit
71
73
  * @param finish Finish the beacon after emitting? _(defaults to `false`)_
72
74
  */
@@ -110,6 +112,7 @@ class Beacon<Value> {
110
112
  type BeaconOptions<Value> = {
111
113
  /**
112
114
  * Method for comparing values for equality
115
+ *
113
116
  * @param first First value
114
117
  * @param second Second value
115
118
  * @returns `true` if the values are equal, otherwise `false`
@@ -148,6 +151,7 @@ class Observable<Value> {
148
151
 
149
152
  /**
150
153
  * Subscribe to value changes
154
+ *
151
155
  * @param onNext Callback for when the observable receives a new value
152
156
  * @param onError Callback for when the observable receives an error
153
157
  * @param onComplete Callback for when the observable is completed
@@ -161,6 +165,7 @@ class Observable<Value> {
161
165
 
162
166
  /**
163
167
  * Subscribe to value changes
168
+ *
164
169
  * @param observer Observer for changes
165
170
  * @returns Subscription to the observable
166
171
  */
@@ -265,6 +270,7 @@ type SubscriptionState<Value> = {
265
270
 
266
271
  /**
267
272
  * Create a new beacon
273
+ *
268
274
  * @param value Initial value
269
275
  * @param options Beacon options
270
276
  * @returns Beacon instance
@@ -5,9 +5,13 @@ import type {HSLAColor, HSLColor, RGBAColor, RGBColor} from './models';
5
5
  // #region Functions
6
6
 
7
7
  /**
8
- * Get a Color from any kind of value
8
+ * Get a _Color_ from any kind of value
9
+ *
10
+ * - Values that can be parsed are: hex(a) color strings, _HSL(A)_ color objects, and _RGB(A)_ color objects
11
+ * - If the value is unable to be parsed, a black _Color_ will be returned
12
+ *
9
13
  * @param value Original value
10
- * @returns Color instance
14
+ * @returns _Color_ instance
11
15
  */
12
16
  export function getColor(value: unknown): Color {
13
17
  return isColor(value) ? value : new Color(value);
@@ -20,14 +20,21 @@ export class Color {
20
20
  readonly #state: ColorState;
21
21
 
22
22
  /**
23
- * Get the alpha channel
23
+ * Get the alpha channel _(opacity)_ of the color
24
+ *
25
+ * @returns Current alpha channel value between `0` and `1`
24
26
  */
25
27
  get alpha(): number {
26
28
  return this.#state.alpha.value;
27
29
  }
28
30
 
29
31
  /**
30
- * Set the alpha channel
32
+ * Set the alpha channel _(opacity)_ of the color, as:
33
+ *
34
+ * - A number between `0` and `1`, where `0` is fully transparent and `1` is fully opaque
35
+ * - A number between `0` and `100`, where `0` is fully transparent and `100` is fully opaque
36
+ *
37
+ * @param value New alpha channel value
31
38
  */
32
39
  set alpha(value: number) {
33
40
  if (typeof value === 'number' && !Number.isNaN(value)) {
@@ -36,49 +43,73 @@ export class Color {
36
43
  }
37
44
 
38
45
  /**
39
- * Get the color as a hex color
46
+ * Get the color as a hex color string
47
+ *
48
+ * _Hex color string is returned with no `#`-prefix or alpha channel (opacity)_
49
+ *
50
+ * @returns Current color as a hex color string
40
51
  */
41
52
  get hex(): string {
42
53
  return this.#state.hex;
43
54
  }
44
55
 
45
56
  /**
46
- * Set colors from a hex color
57
+ * Set the color from a hex color string
58
+ *
59
+ * - `#`-prefix is optional
60
+ * - Alpha channel _(opacity)_ will be ignored
61
+ *
62
+ * @param value New hex color string
47
63
  */
48
64
  set hex(value: string) {
49
65
  setHexColor(this.#state, value, false);
50
66
  }
51
67
 
52
68
  /**
53
- * Get the color as a hex color with an alpha channel
69
+ * Get the color as a hex color with an alpha channel _(opacity)_
70
+ *
71
+ * _Hex color string is returned with alpha channel (opacity), but without `#`-prefix_
72
+ *
73
+ * @returns Current color as a hex color string
54
74
  */
55
75
  get hexa(): string {
56
76
  return `${this.#state.hex}${this.#state.alpha.hex}`;
57
77
  }
58
78
 
59
79
  /**
60
- * Set colors and alpha from a hex color with an alpha channel
80
+ * Set the color from a hex color string with an alpha channel _(opacity)_
81
+ *
82
+ * - `#`-prefix is optional
83
+ * - Alpha channel _(opacity)_ will be respected
84
+ *
85
+ * @param value New hex color string
61
86
  */
62
87
  set hexa(value: string) {
63
88
  setHexColor(this.#state, value, true);
64
89
  }
65
90
 
66
91
  /**
67
- * Get the color as an HSL color
92
+ * Get the color as an _HSL_ color
93
+ *
94
+ * @returns Current color as an _HSL_ color
68
95
  */
69
96
  get hsl(): HSLColor {
70
97
  return this.#state.hsl;
71
98
  }
72
99
 
73
100
  /**
74
- * Set colors from an HSL color
101
+ * Set colors from an _HSL_ color
102
+ *
103
+ * @param value New _HSL_ color
75
104
  */
76
105
  set hsl(value: HSLColor) {
77
106
  setHSLColor(this.#state, value, false);
78
107
  }
79
108
 
80
109
  /**
81
- * Get the color as an HSLA color
110
+ * Get the color as an _HSLA_ color
111
+ *
112
+ * @returns Current color as an _HSLA_ color
82
113
  */
83
114
  get hsla(): HSLAColor {
84
115
  return {
@@ -88,28 +119,36 @@ export class Color {
88
119
  }
89
120
 
90
121
  /**
91
- * Set colors and alpha from an HSLA color
122
+ * Set colors and alpha from an _HSLA_ color
123
+ *
124
+ * @param value New _HSLA_ color
92
125
  */
93
126
  set hsla(value: HSLAColor) {
94
127
  setHSLColor(this.#state, value, true);
95
128
  }
96
129
 
97
130
  /**
98
- * Get the color as an RGB color
131
+ * Get the color as an _RGB_ color
132
+ *
133
+ * @returns Current color as an _RGB_ color
99
134
  */
100
135
  get rgb(): RGBColor {
101
136
  return this.#state.rgb;
102
137
  }
103
138
 
104
139
  /**
105
- * Set colors from an RGB color
140
+ * Set colors from an _RGB_ color
141
+ *
142
+ * @param value New _RGB_ color
106
143
  */
107
144
  set rgb(value: RGBColor) {
108
145
  setRGBColor(this.#state, value, false);
109
146
  }
110
147
 
111
148
  /**
112
- * Get the color as an RGBA color
149
+ * Get the color as an _RGBA_ color
150
+ *
151
+ * @returns Current color as an _RGBA_ color
113
152
  */
114
153
  get rgba(): RGBAColor {
115
154
  return {
@@ -119,7 +158,9 @@ export class Color {
119
158
  }
120
159
 
121
160
  /**
122
- * Set colors and alpha from an RGBA color
161
+ * Set colors and alpha from an _RGBA_ color
162
+ *
163
+ * @param value New _RGBA_ color
123
164
  */
124
165
  set rgba(value: RGBAColor) {
125
166
  setRGBColor(this.#state, value, true);
@@ -133,18 +174,41 @@ export class Color {
133
174
  });
134
175
  }
135
176
 
177
+ /**
178
+ * Get the color as a hex string
179
+ *
180
+ * @param alpha Include alpha channel _(opacity)_? _(defaults to `false`)_
181
+ * @returns Hex color string
182
+ */
136
183
  toHexString(alpha?: boolean): string {
137
184
  return `#${alpha === true ? this.hexa : this.hex}`;
138
185
  }
139
186
 
187
+ /**
188
+ * Get the color as an _HSL(A)_ string
189
+ *
190
+ * @param alpha Include alpha channel _(opacity)_? _(defaults to `false`)_
191
+ * @returns _HSL(A)_ color string
192
+ */
140
193
  toHslString(alpha?: boolean): string {
141
194
  return formatColor(SPACE_HSL, this, alpha === true);
142
195
  }
143
196
 
197
+ /**
198
+ * Get the color as an _RGB(A)_ string
199
+ *
200
+ * @param alpha Include alpha channel _(opacity)_? _(defaults to `false`)_
201
+ * @returns _RGB(A)_ color string
202
+ */
144
203
  toRgbString(alpha?: boolean): string {
145
204
  return formatColor(SPACE_RGB, this, alpha === true);
146
205
  }
147
206
 
207
+ /**
208
+ * Get the color as a hex color string
209
+ *
210
+ * @returns Hex color string
211
+ */
148
212
  toString(): string {
149
213
  return this.toHexString();
150
214
  }
@@ -27,6 +27,10 @@ function getClampedValue(value: unknown, minimum: number, maximum: number): numb
27
27
 
28
28
  /**
29
29
  * Get a foreground color _(usually text)_ based on a background color's luminance
30
+ *
31
+ * - Values that can be parsed are: hex(a) color strings, _HSL(A)_ color objects, and _RGB(A)_ color objects
32
+ * - If the value cannot be parsed, a white foreground color will be returned
33
+ *
30
34
  * @param value Original value
31
35
  * @returns Foreground color
32
36
  */
@@ -58,9 +62,13 @@ export function getForegroundColor(value: unknown): Color {
58
62
  }
59
63
 
60
64
  /**
61
- * Get the hex color _(with alpha channel)_ from any kind of value
65
+ * Get the hex color _(with alpha channel, i.e., opacity)_ from any kind of value
66
+ *
67
+ * - Values that can be parsed are: hex(a) color strings, _HSL(A)_ color objects, and _RGB(A)_ color objects
68
+ * - If the value cannot be parsed, a black hex color with an alpha channel of `0` will be returned
69
+ *
62
70
  * @param value Original value
63
- * @returns Hex color
71
+ * @returns Hex color string
64
72
  */
65
73
  export function getHexaColor(value: unknown): string {
66
74
  const {alpha, hex} = getColorState(value);
@@ -70,8 +78,12 @@ export function getHexaColor(value: unknown): string {
70
78
 
71
79
  /**
72
80
  * Get the hex color from any kind of value
81
+ *
82
+ * - Values that can be parsed are: hex(a) color strings, _HSL(A)_ color objects, and _RGB(A)_ color objects
83
+ * - If the value cannot be parsed, a black hex color will be returned
84
+ *
73
85
  * @param value Original value
74
- * @returns Hex color
86
+ * @returns Hex color string
75
87
  */
76
88
  export function getHexColor(value: unknown): string {
77
89
  return getColorState(value).hex;
@@ -86,9 +98,13 @@ export function getDegrees(value: unknown): number {
86
98
  }
87
99
 
88
100
  /**
89
- * Get the HSLA color from any kind of value
101
+ * Get the _HSLA_ color from any kind of value
102
+ *
103
+ * - Values that can be parsed are: hex(a) color strings, _HSL(A)_ color objects, and _RGB(A)_ color objects
104
+ * - If the value cannot be parsed, a black _HSLA_ color with an alpha channel _(opacity)_ of `0` will be returned
105
+ *
90
106
  * @param value Original value
91
- * @returns HSLA color
107
+ * @returns _HSLA_ color
92
108
  */
93
109
  export function getHslaColor(value: unknown): HSLAColor {
94
110
  const {alpha, hsl} = getColorState(value);
@@ -100,9 +116,13 @@ export function getHslaColor(value: unknown): HSLAColor {
100
116
  }
101
117
 
102
118
  /**
103
- * Get the HSL color from any kind of value
119
+ * Get the _HSL_ color from any kind of value
120
+ *
121
+ * - Values that can be parsed are: hex(a) color strings, _HSL(A)_ color objects, and _RGB(A)_ color objects
122
+ * - If the value cannot be parsed, a black _HSL_ color will be returned
123
+ *
104
124
  * @param value Original value
105
- * @returns HSL color
125
+ * @returns _HSL_ color
106
126
  */
107
127
  export function getHslColor(value: unknown): HSLColor {
108
128
  return getColorState(value).hsl;
@@ -113,9 +133,13 @@ export function getPercentage(value: unknown): number {
113
133
  }
114
134
 
115
135
  /**
116
- * Get the RGBA color from any kind of value
136
+ * Get the _RGBA_ color from any kind of value
137
+ *
138
+ * - Values that can be parsed are: hex(a) color strings, _HSL(A)_ color objects, and _RGB(A)_ color objects
139
+ * - If the value cannot be parsed, a black _RGBA_ color with an alpha channel _(opacity)_ of `0` will be returned
140
+ *
117
141
  * @param value Original value
118
- * @returns RGBA color
142
+ * @returns _RGBA_ color
119
143
  */
120
144
  export function getRgbaColor(value: unknown): RGBAColor {
121
145
  const {alpha, rgb} = getColorState(value);
@@ -127,9 +151,13 @@ export function getRgbaColor(value: unknown): RGBAColor {
127
151
  }
128
152
 
129
153
  /**
130
- * Get the RGB color from any kind of value
154
+ * Get the _RGB_ color from any kind of value
155
+ *
156
+ * - Values that can be parsed are: hex(a) color strings, _HSL(A)_ color objects, and _RGB(A)_ color objects
157
+ * - If the value cannot be parsed, a black _RGB_ color will be returned
158
+ *
131
159
  * @param value Original value
132
- * @returns RGB color
160
+ * @returns _RGB_ color
133
161
  */
134
162
  export function getRgbColor(value: unknown): RGBColor {
135
163
  return getColorState(value).rgb;