@oscarpalmer/atoms 0.212.0 → 0.214.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 (258) hide show
  1. package/dist/array/difference.d.mts +1 -1
  2. package/dist/array/difference.mjs +3 -2
  3. package/dist/array/exists.d.mts +1 -1
  4. package/dist/array/exists.mjs +3 -2
  5. package/dist/array/filter.d.mts +1 -1
  6. package/dist/array/filter.mjs +1 -0
  7. package/dist/array/find.d.mts +1 -1
  8. package/dist/array/find.mjs +4 -3
  9. package/dist/array/first.d.mts +1 -1
  10. package/dist/array/flatten.d.mts +1 -1
  11. package/dist/array/group-by.d.mts +1 -1
  12. package/dist/array/index.d.mts +2 -2
  13. package/dist/array/insert.mjs +3 -2
  14. package/dist/array/intersection.mjs +3 -2
  15. package/dist/array/last.d.mts +1 -1
  16. package/dist/array/move.d.mts +1 -1
  17. package/dist/array/partition.d.mts +1 -1
  18. package/dist/array/partition.mjs +1 -0
  19. package/dist/array/push.mjs +3 -2
  20. package/dist/array/select.d.mts +10 -12
  21. package/dist/array/select.mjs +1 -0
  22. package/dist/array/single.d.mts +1 -1
  23. package/dist/array/single.mjs +1 -0
  24. package/dist/array/slice.d.mts +1 -1
  25. package/dist/array/slice.mjs +4 -5
  26. package/dist/array/sort.d.mts +4 -103
  27. package/dist/array/sort.mjs +6 -14
  28. package/dist/array/splice.mjs +3 -2
  29. package/dist/array/swap.d.mts +1 -1
  30. package/dist/array/to-map.d.mts +1 -1
  31. package/dist/array/to-record.d.mts +1 -1
  32. package/dist/array/to-set.d.mts +1 -1
  33. package/dist/array/toggle.d.mts +1 -1
  34. package/dist/array/union.mjs +3 -2
  35. package/dist/array/unique.d.mts +1 -1
  36. package/dist/array/unique.mjs +3 -2
  37. package/dist/array/update.d.mts +1 -1
  38. package/dist/beacon.d.mts +6 -92
  39. package/dist/beacon.mjs +6 -16
  40. package/dist/color/constants.d.mts +2 -2
  41. package/dist/color/constants.mjs +1 -1
  42. package/dist/color/index.d.mts +1 -1
  43. package/dist/color/instance.d.mts +1 -1
  44. package/dist/color/instance.mjs +0 -1
  45. package/dist/color/misc/alpha.d.mts +1 -1
  46. package/dist/color/misc/format.d.mts +1 -1
  47. package/dist/color/misc/get.d.mts +1 -1
  48. package/dist/color/misc/is.d.mts +2 -2
  49. package/dist/color/misc/is.mjs +1 -0
  50. package/dist/color/misc/state.d.mts +1 -1
  51. package/dist/color/space/hex.d.mts +1 -1
  52. package/dist/color/space/hsl.d.mts +1 -1
  53. package/dist/color/space/hwb.d.mts +1 -1
  54. package/dist/color/space/rgb.d.mts +1 -1
  55. package/dist/function/limit.d.mts +2 -2
  56. package/dist/function/limit.mjs +2 -1
  57. package/dist/function/once.d.mts +7 -3
  58. package/dist/function/once.mjs +5 -10
  59. package/dist/function/retry.d.mts +4 -14
  60. package/dist/function/retry.mjs +3 -15
  61. package/dist/herald.d.mts +2 -2
  62. package/dist/index.d.mts +466 -351
  63. package/dist/index.mjs +491 -439
  64. package/dist/internal/aborter.d.mts +1 -6
  65. package/dist/internal/aborter.mjs +3 -4
  66. package/dist/internal/array/callbacks.d.mts +3 -7
  67. package/dist/internal/array/chunk.mjs +2 -2
  68. package/dist/internal/array/find.d.mts +5 -23
  69. package/dist/internal/array/find.mjs +5 -9
  70. package/dist/internal/array/get.d.mts +1 -1
  71. package/dist/internal/array/group.d.mts +1 -1
  72. package/dist/internal/array/index-of.d.mts +1 -1
  73. package/dist/internal/array/index-of.mjs +4 -3
  74. package/dist/internal/array/insert.d.mts +2 -5
  75. package/dist/internal/array/insert.mjs +2 -4
  76. package/dist/internal/array/match.d.mts +2 -5
  77. package/dist/internal/array/match.mjs +10 -20
  78. package/dist/internal/array/overlap.d.mts +2 -10
  79. package/dist/internal/array/sets.d.mts +2 -5
  80. package/dist/internal/array/sets.mjs +5 -7
  81. package/dist/internal/function/assert.d.mts +5 -12
  82. package/dist/internal/function/assert.mjs +2 -2
  83. package/dist/internal/function/limit.d.mts +2 -37
  84. package/dist/internal/function/limit.mjs +4 -15
  85. package/dist/internal/function/memoize.d.mts +5 -70
  86. package/dist/internal/function/memoize.mjs +2 -5
  87. package/dist/internal/function/work.d.mts +16 -22
  88. package/dist/internal/function/work.mjs +1 -8
  89. package/dist/internal/herald.d.mts +3 -3
  90. package/dist/internal/herald.mjs +2 -1
  91. package/dist/internal/is.d.mts +1 -1
  92. package/dist/internal/math/aggregate.d.mts +2 -14
  93. package/dist/internal/math/aggregate.mjs +2 -5
  94. package/dist/internal/number.mjs +4 -7
  95. package/dist/internal/result/attempt.d.mts +1 -1
  96. package/dist/internal/result/misc.d.mts +1 -1
  97. package/dist/internal/string/case.mjs +6 -16
  98. package/dist/internal/string/misc.mjs +1 -3
  99. package/dist/internal/subscription.d.mts +1 -100
  100. package/dist/internal/subscription.mjs +3 -9
  101. package/dist/internal/value/compare.d.mts +4 -4
  102. package/dist/internal/value/compare.mjs +1 -1
  103. package/dist/internal/value/equal.d.mts +6 -57
  104. package/dist/internal/value/equal.mjs +5 -10
  105. package/dist/internal/value/get.d.mts +1 -1
  106. package/dist/internal/value/handlers.d.mts +2 -21
  107. package/dist/internal/value/has.d.mts +2 -2
  108. package/dist/internal/value/misc.d.mts +1 -1
  109. package/dist/internal/value/misc.mjs +8 -14
  110. package/dist/internal/value/set.d.mts +1 -1
  111. package/dist/internal/value/set.mjs +2 -2
  112. package/dist/is.mjs +3 -3
  113. package/dist/logger.d.mts +3 -70
  114. package/dist/logger.mjs +2 -5
  115. package/dist/math.d.mts +1 -1
  116. package/dist/math.mjs +2 -1
  117. package/dist/models/aborter.model.d.mts +12 -0
  118. package/dist/models/aborter.model.mjs +5 -0
  119. package/dist/models/array/array.find.model.d.mts +22 -0
  120. package/dist/models/array/array.find.model.mjs +8 -0
  121. package/dist/models/array/array.match.model.d.mts +14 -0
  122. package/dist/models/array/array.match.model.mjs +14 -0
  123. package/dist/models/array/array.misc.model.d.mts +36 -0
  124. package/dist/models/array/array.misc.model.mjs +12 -0
  125. package/dist/models/array/array.sort.model.d.mts +122 -0
  126. package/dist/models/array/array.sort.model.mjs +12 -0
  127. package/dist/models/beacon.model.d.mts +119 -0
  128. package/dist/models/beacon.model.mjs +16 -0
  129. package/dist/{color/models.d.mts → models/color.model.d.mts} +4 -4
  130. package/dist/models/function/assert.model.d.mts +13 -0
  131. package/dist/models/function/assert.model.mjs +4 -0
  132. package/dist/models/function/limiter.model.d.mts +71 -0
  133. package/dist/models/function/limiter.model.mjs +15 -0
  134. package/dist/models/function/memoize.model.d.mts +88 -0
  135. package/dist/models/function/memoize.model.mjs +7 -0
  136. package/dist/models/function/once.model.d.mts +76 -0
  137. package/dist/models/function/once.model.mjs +9 -0
  138. package/dist/models/function/retry.model.d.mts +17 -0
  139. package/dist/models/function/retry.model.mjs +17 -0
  140. package/dist/models/function/work.model.d.mts +20 -0
  141. package/dist/models/function/work.model.mjs +11 -0
  142. package/dist/{internal/models → models}/herald.model.d.mts +3 -3
  143. package/dist/{internal/models → models}/herald.model.mjs +2 -2
  144. package/dist/{models.d.mts → models/index.d.mts} +8 -50
  145. package/dist/models/logger.model.d.mts +83 -0
  146. package/dist/models/logger.model.mjs +7 -0
  147. package/dist/models/math.model.d.mts +16 -0
  148. package/dist/models/math.model.mjs +7 -0
  149. package/dist/models/misc.model.d.mts +10 -0
  150. package/dist/models/misc.model.mjs +11 -0
  151. package/dist/{internal/models → models}/plan.model.d.mts +17 -15
  152. package/dist/{internal/models → models}/plan.model.mjs +1 -1
  153. package/dist/models/promise.model.d.mts +119 -0
  154. package/dist/models/promise.model.mjs +47 -0
  155. package/dist/models/query.model.d.mts +9 -0
  156. package/dist/models/query.model.mjs +14 -0
  157. package/dist/models/queue.model.d.mts +251 -0
  158. package/dist/models/queue.model.mjs +29 -0
  159. package/dist/models/random.model.d.mts +6 -0
  160. package/dist/models/random.model.mjs +7 -0
  161. package/dist/{internal/models → models}/result.model.d.mts +10 -2
  162. package/dist/models/string/string.case.model.d.mts +19 -0
  163. package/dist/models/string/string.case.model.mjs +14 -0
  164. package/dist/models/string/string.fuzzy.model.d.mts +108 -0
  165. package/dist/models/string/string.fuzzy.model.mjs +9 -0
  166. package/dist/models/string/string.misc.model.d.mts +13 -0
  167. package/dist/models/string/string.misc.model.mjs +13 -0
  168. package/dist/models/string/string.normalize.model.d.mts +85 -0
  169. package/dist/models/string/string.normalize.model.mjs +43 -0
  170. package/dist/models/string/string.template.model.d.mts +50 -0
  171. package/dist/models/string/string.template.model.mjs +5 -0
  172. package/dist/models/subscription.model.d.mts +127 -0
  173. package/dist/models/subscription.model.mjs +10 -0
  174. package/dist/models/value/value.clone.model.d.mts +56 -0
  175. package/dist/models/value/value.clone.model.mjs +24 -0
  176. package/dist/models/value/value.diff.model.d.mts +61 -0
  177. package/dist/models/value/value.diff.model.mjs +6 -0
  178. package/dist/models/value/value.equal.model.d.mts +76 -0
  179. package/dist/models/value/value.equal.model.mjs +9 -0
  180. package/dist/models/value/value.handler.model.d.mts +27 -0
  181. package/dist/models/value/value.handler.model.mjs +1 -0
  182. package/dist/models/value/value.merge.model.d.mts +82 -0
  183. package/dist/models/value/value.merge.model.mjs +5 -0
  184. package/dist/models/value/value.misc.model.d.mts +33 -0
  185. package/dist/models/value/value.misc.model.mjs +12 -0
  186. package/dist/models/value/value.transform.model.d.mts +28 -0
  187. package/dist/models/value/value.transform.model.mjs +4 -0
  188. package/dist/plan/generate.d.mts +3 -2
  189. package/dist/plan/generate.mjs +14 -10
  190. package/dist/plan/index.d.mts +1 -1
  191. package/dist/plan/index.mjs +2 -2
  192. package/dist/plan/is.d.mts +31 -2
  193. package/dist/plan/is.mjs +45 -1
  194. package/dist/plan/misc.d.mts +21 -2
  195. package/dist/plan/misc.mjs +32 -2
  196. package/dist/plan/models.d.mts +1 -1
  197. package/dist/plan/result.d.mts +7 -7
  198. package/dist/plan/result.mjs +6 -6
  199. package/dist/plan/run.d.mts +5 -5
  200. package/dist/plan/run.mjs +6 -6
  201. package/dist/promise/delay.d.mts +1 -1
  202. package/dist/promise/delay.mjs +2 -1
  203. package/dist/promise/helpers.d.mts +2 -2
  204. package/dist/promise/helpers.mjs +6 -6
  205. package/dist/promise/index.d.mts +2 -2
  206. package/dist/promise/index.mjs +1 -1
  207. package/dist/promise/misc.d.mts +3 -3
  208. package/dist/promise/misc.mjs +7 -4
  209. package/dist/promise/models.d.mts +2 -106
  210. package/dist/promise/models.mjs +1 -35
  211. package/dist/promise/timed.d.mts +2 -2
  212. package/dist/promise/timed.mjs +3 -3
  213. package/dist/query.d.mts +1 -1
  214. package/dist/query.mjs +5 -15
  215. package/dist/queue.d.mts +6 -200
  216. package/dist/queue.mjs +9 -34
  217. package/dist/random.mjs +2 -5
  218. package/dist/result/match.d.mts +1 -1
  219. package/dist/result/match.mjs +27 -15
  220. package/dist/result/misc.d.mts +1 -1
  221. package/dist/result/work/flow.d.mts +13 -21
  222. package/dist/result/work/flow.mjs +0 -1
  223. package/dist/result/work/pipe.d.mts +2 -2
  224. package/dist/result/work/pipe.mjs +0 -1
  225. package/dist/string/fuzzy.d.mts +5 -87
  226. package/dist/string/fuzzy.mjs +6 -11
  227. package/dist/string/index.mjs +6 -8
  228. package/dist/string/match.mjs +4 -6
  229. package/dist/string/normalize.d.mts +4 -40
  230. package/dist/string/normalize.mjs +9 -48
  231. package/dist/string/template.d.mts +5 -43
  232. package/dist/string/template.mjs +1 -2
  233. package/dist/subscription.d.mts +2 -1
  234. package/dist/value/clone.d.mts +6 -42
  235. package/dist/value/clone.mjs +10 -30
  236. package/dist/value/collection.mjs +2 -0
  237. package/dist/value/diff.d.mts +3 -44
  238. package/dist/value/diff.mjs +1 -3
  239. package/dist/value/freeze.d.mts +1 -5
  240. package/dist/value/index.d.mts +4 -3
  241. package/dist/value/merge.d.mts +6 -64
  242. package/dist/value/merge.mjs +8 -8
  243. package/dist/value/omit.d.mts +1 -1
  244. package/dist/value/pick.d.mts +1 -1
  245. package/dist/value/shake.d.mts +4 -6
  246. package/dist/value/smush.d.mts +4 -6
  247. package/dist/value/smush.mjs +2 -2
  248. package/dist/value/transform.d.mts +6 -22
  249. package/dist/value/transform.mjs +1 -1
  250. package/dist/value/unsmush.d.mts +4 -10
  251. package/package.json +12 -3
  252. package/dist/internal/plan.d.mts +0 -45
  253. package/dist/internal/plan.mjs +0 -70
  254. package/dist/promise/constants.d.mts +0 -17
  255. package/dist/promise/constants.mjs +0 -15
  256. /package/dist/{color/models.mjs → models/color.model.mjs} +0 -0
  257. /package/dist/{internal/models/result.model.mjs → models/index.mjs} +0 -0
  258. /package/dist/{models.mjs → models/result.model.mjs} +0 -0
package/dist/beacon.d.mts CHANGED
@@ -1,95 +1,8 @@
1
- import { Subscription } from "./internal/subscription.mjs";
1
+ import { Subscription } from "./models/subscription.model.mjs";
2
+ import { Beacon, BeaconOptions, BeaconState, Observable, Observer } from "./models/beacon.model.mjs";
2
3
  //#region src/beacon.d.ts
3
- /**
4
- * A beacon is a lighthouse, holding an observable value that can be subscribed to and emitted from
5
- */
6
- export type Beacon<Value> = {
7
- /**
8
- * Is the beacon active?
9
- */
10
- get active(): boolean;
11
- /**
12
- * The observable that can be subscribed to
13
- */
14
- get observable(): Observable<Value>;
15
- /**
16
- * The current value
17
- */
18
- get value(): Value;
19
- /**
20
- * Deactivate the beacon
21
- */
22
- deactivate(): void;
23
- /**
24
- * Emit a new value
25
- *
26
- * @param value Value to set and emit
27
- * @param finish Finish the beacon after emitting? _(defaults to `false`)_
28
- */
29
- emit(value: Value, finish?: boolean): void;
30
- /**
31
- * Emit an error
32
- *
33
- * @param value Error to emit
34
- * @param finish Finish the beacon after emitting? _(defaults to `false`)_
35
- */
36
- error(value: Error, finish?: boolean): void;
37
- /**
38
- * Finish the beacon
39
- */
40
- finish(): void;
41
- };
42
- export type BeaconOptions<Value> = {
43
- /**
44
- * Method for comparing values for equality
45
- *
46
- * @param first First value
47
- * @param second Second value
48
- * @returns `true` if the values are equal, otherwise `false`
49
- * @default Object.is
50
- */
51
- equal?: (first: Value, second: Value) => boolean;
52
- };
53
- export type Observable<Value> = {
54
- /**
55
- * Is the observable active?
56
- */
57
- get active(): boolean;
58
- /**
59
- * Deactivate the observable
60
- */
61
- deactivate(): void;
62
- /**
63
- * Subscribe to value changes
64
- *
65
- * @param onNext Callback for when the observable receives a new value
66
- * @param onError Callback for when the observable receives an error
67
- * @param onComplete Callback for when the observable is completed
68
- * @returns Subscription to the observable
69
- */
70
- subscribe(onNext: (value: Value) => void, onError?: (error: Error) => void, onComplete?: () => void): Subscription;
71
- /**
72
- * Subscribe to value changes
73
- *
74
- * @param observer Observer for changes
75
- * @returns Subscription to the observable
76
- */
77
- subscribe(observer: Observer<Value>): Subscription;
78
- };
79
- type Observer<Value> = {
80
- /**
81
- * Callback for when the observable is completed
82
- */
83
- complete?: () => void;
84
- /**
85
- * Callback for when the observable receives an error
86
- */
87
- error?: (error: Error) => void;
88
- /**
89
- * Callback for when the observable receives a new value
90
- */
91
- next?: (value: Value) => void;
92
- };
4
+ declare function Beacon(this: any, value: unknown, options?: BeaconOptions<unknown>): void;
5
+ declare function Observable(this: any, beacon: BeaconState<unknown>): void;
93
6
  /**
94
7
  * Create a new beacon
95
8
  *
@@ -119,4 +32,5 @@ export declare function isBeaconSubscription(value: unknown): value is Subscript
119
32
  * @returns `true` if the value is an observable, otherwise `false`
120
33
  */
121
34
  export declare function isObservable<Value = unknown>(value: unknown): value is Observable<Value>;
122
- //#endregion
35
+ //#endregion
36
+ export type { Beacon, BeaconOptions, Observable, Observer };
package/dist/beacon.mjs CHANGED
@@ -1,10 +1,9 @@
1
1
  import { noop } from "./internal/function/misc.mjs";
2
2
  import { isPlainObject } from "./internal/is.mjs";
3
- import { SUBSCRIPTION_NAME, isSubscription, subscriptions } from "./internal/subscription.mjs";
3
+ import "./models/subscription.model.mjs";
4
+ import { isSubscription, subscriptions } from "./internal/subscription.mjs";
5
+ import { BEACON_MESSAGE_RETRIEVE, BEACON_MESSAGE_SUBSCRIBE, BEACON_NAME, BEACON_OBSERVABLE, BEACON_PROPERTY, BEACON_SYMBOL, BEACON_TYPE_ERROR, BEACON_TYPE_NEXT, beaconSubscription } from "./models/beacon.model.mjs";
4
6
  //#region src/beacon.ts
5
- const BEACON_PROPERTY = "$beacon";
6
- const BEACON_NAME = "beacon";
7
- const BEACON_OBSERVABLE = "observable";
8
7
  function Beacon(value, options) {
9
8
  this[BEACON_SYMBOL] = {
10
9
  value,
@@ -128,7 +127,7 @@ function isBeacon(value) {
128
127
  return isBeaconInstance(BEACON_NAME, value);
129
128
  }
130
129
  function isBeaconInstance(name, value) {
131
- return typeof value === "object" && value !== null && BEACON_PROPERTY in value && value[BEACON_PROPERTY] === name;
130
+ return typeof value === "object" && value !== null && "$beacon" in value && value["$beacon"] === name;
132
131
  }
133
132
  /**
134
133
  * Is the value a beacon subscription?
@@ -137,7 +136,7 @@ function isBeaconInstance(name, value) {
137
136
  * @returns `true` if the value is a beacon subscription, otherwise `false`
138
137
  */
139
138
  function isBeaconSubscription(value) {
140
- return isSubscription(value) && value[BEACON_PROPERTY] === "subscription";
139
+ return isSubscription(value) && value["$beacon"] === "subscription";
141
140
  }
142
141
  /**
143
142
  * Is the value an observable?
@@ -163,7 +162,7 @@ function subscribeToObservable(first, second, third) {
163
162
  function updateBeacon(instance, type, value, finish) {
164
163
  const state = instance[BEACON_SYMBOL];
165
164
  if (!state.active) return;
166
- if (type === BEACON_TYPE_NEXT) {
165
+ if (type === "next") {
167
166
  if (state.options.equal(state.value, value)) return;
168
167
  state.value = value;
169
168
  }
@@ -171,14 +170,5 @@ function updateBeacon(instance, type, value, finish) {
171
170
  if (subscriptions != null && subscriptions.size > 0) for (const [, observer] of subscriptions) observer[type]?.(value);
172
171
  if (finish === true) closeBeacon(state, true);
173
172
  }
174
- const BEACON_MESSAGE_RETRIEVE = "Cannot retrieve observable from a closed beacon";
175
- const BEACON_MESSAGE_SUBSCRIBE = "Cannot subscribe to a closed observable";
176
- const BEACON_SYMBOL = Symbol(BEACON_PROPERTY);
177
- const BEACON_TYPE_ERROR = "error";
178
- const BEACON_TYPE_NEXT = "next";
179
- const beaconSubscription = {
180
- key: BEACON_PROPERTY,
181
- value: SUBSCRIPTION_NAME
182
- };
183
173
  //#endregion
184
174
  export { beacon, isBeacon, isBeaconSubscription, isObservable };
@@ -1,5 +1,5 @@
1
- import { SubscriptionProperty } from "../internal/subscription.mjs";
2
- import { ColorDefaults, ColorExpressions, ColorTypeExtended, HSLAColor, HSLColor, HWBAColor, HWBColor, RGBAColor, RGBColor } from "./models.mjs";
1
+ import { SubscriptionProperty } from "../models/subscription.model.mjs";
2
+ import { ColorDefaults, ColorExpressions, ColorTypeExtended, HSLAColor, HSLColor, HWBAColor, HWBColor, RGBAColor, RGBColor } from "../models/color.model.mjs";
3
3
  //#region src/color/constants.d.ts
4
4
  type ColorTypes = {
5
5
  all: Set<"alpha" | ColorTypeExtended>;
@@ -1,4 +1,4 @@
1
- import { SUBSCRIPTION_NAME } from "../internal/subscription.mjs";
1
+ import { SUBSCRIPTION_NAME } from "../models/subscription.model.mjs";
2
2
  //#region src/color/constants.ts
3
3
  const COLOR_ALPHA = {
4
4
  fullHexShort: "f",
@@ -1,4 +1,4 @@
1
- import { Color, ColorType, ColorTypeExtended, ColorValue, ColorValueExtended, HSLAColor, HSLColor, HWBAColor, HWBColor, RGBAColor, RGBColor } from "./models.mjs";
1
+ import { Color, ColorType, ColorTypeExtended, ColorValue, ColorValueExtended, HSLAColor, HSLColor, HWBAColor, HWBColor, RGBAColor, RGBColor } from "../models/color.model.mjs";
2
2
  import { getForegroundColor, getHexColor, getHexaColor, getHslColor, getHslaColor, getHwbColor, getHwbaColor, getRgbColor, getRgbaColor } from "./misc/get.mjs";
3
3
  import { isColor, isHexColor, isHslColor, isHslaColor, isHwbColor, isHwbaColor, isRgbColor, isRgbaColor } from "./misc/is.mjs";
4
4
  import { getNormalizedHex, hexToHsl, hexToHsla, hexToHwb, hexToHwba, hexToRgb, hexToRgba } from "./space/hex.mjs";
@@ -1,4 +1,4 @@
1
- import { Color } from "./models.mjs";
1
+ import { Color } from "../models/color.model.mjs";
2
2
  //#region src/color/instance.d.ts
3
3
  export declare function color(value: unknown): Color;
4
4
  //#endregion
@@ -1,4 +1,3 @@
1
- import "../internal/subscription.mjs";
2
1
  import { herald } from "../internal/herald.mjs";
3
2
  import { COLOR_NAME, COLOR_PROPERTY, COLOR_SYMBOL, COLOR_TYPE, colorSubscription } from "./constants.mjs";
4
3
  import { getColorAlpha, setColorAlpha } from "./misc/alpha.mjs";
@@ -1,4 +1,4 @@
1
- import { Alpha, InternalColor } from "../models.mjs";
1
+ import { Alpha, InternalColor } from "../../models/color.model.mjs";
2
2
  //#region src/color/misc/alpha.d.ts
3
3
  export declare function getAlpha(value: unknown, hex: boolean): Alpha;
4
4
  export declare function getColorAlpha(this: InternalColor): number;
@@ -1,4 +1,4 @@
1
- import { InternalColor } from "../models.mjs";
1
+ import { InternalColor } from "../../models/color.model.mjs";
2
2
  //#region src/color/misc/format.d.ts
3
3
  export declare function formatHexColor(this: InternalColor, alpha?: boolean): string;
4
4
  export declare function formatHslColor(this: InternalColor, alpha?: boolean): string;
@@ -1,4 +1,4 @@
1
- import { Color, HSLAColor, HSLColor, HWBAColor, HWBColor, RGBAColor, RGBColor } from "../models.mjs";
1
+ import { Color, HSLAColor, HSLColor, HWBAColor, HWBColor, RGBAColor, RGBColor } from "../../models/color.model.mjs";
2
2
  //#region src/color/misc/get.d.ts
3
3
  /**
4
4
  * Get a foreground color _(usually text)_ based on a background color's luminance as an unprefixed hex color string
@@ -1,5 +1,5 @@
1
- import { Subscription } from "../../internal/subscription.mjs";
2
- import { Color, HSLAColor, HSLColor, HWBAColor, HWBColor, RGBAColor, RGBColor } from "../models.mjs";
1
+ import { Subscription } from "../../models/subscription.model.mjs";
2
+ import { Color, HSLAColor, HSLColor, HWBAColor, HWBColor, RGBAColor, RGBColor } from "../../models/color.model.mjs";
3
3
  //#region src/color/misc/is.d.ts
4
4
  /**
5
5
  * Is the value a _Color_?
@@ -1,3 +1,4 @@
1
+ import "../../models/subscription.model.mjs";
1
2
  import { isSubscription } from "../../internal/subscription.mjs";
2
3
  import { between } from "../../internal/number.mjs";
3
4
  import { COLOR_ALPHA, COLOR_EXPRESSION, COLOR_KEYS, COLOR_LENGTHS, COLOR_MAX } from "../constants.mjs";
@@ -1,4 +1,4 @@
1
- import { ColorState, ColorType, HSLAColor, HSLColor, HWBAColor, HWBColor, InternalColor, RGBAColor, RGBColor } from "../models.mjs";
1
+ import { ColorState, ColorType, HSLAColor, HSLColor, HWBAColor, HWBColor, InternalColor, RGBAColor, RGBColor } from "../../models/color.model.mjs";
2
2
  //#region src/color/misc/state.d.ts
3
3
  export declare function getColorFromState<Type extends ColorType>(state: ColorState, type: Type): NonNullable<ColorState[Type]>;
4
4
  export declare function getColorState(value: unknown): ColorState;
@@ -1,4 +1,4 @@
1
- import { ColorState, ColorType, HSLAColor, HSLColor, HWBAColor, HWBColor, InternalColor, RGBAColor, RGBColor } from "../models.mjs";
1
+ import { ColorState, ColorType, HSLAColor, HSLColor, HWBAColor, HWBColor, InternalColor, RGBAColor, RGBColor } from "../../models/color.model.mjs";
2
2
  //#region src/color/space/hex.d.ts
3
3
  export declare function getColorFromHex<Type extends ColorType>(state: ColorState, type: Type): NonNullable<ColorState[Type]>;
4
4
  export declare function getHexColor(this: InternalColor): string;
@@ -1,4 +1,4 @@
1
- import { ColorState, ColorType, HSLAColor, HSLColor, HWBAColor, HWBColor, InternalColor, RGBAColor, RGBColor } from "../models.mjs";
1
+ import { ColorState, ColorType, HSLAColor, HSLColor, HWBAColor, HWBColor, InternalColor, RGBAColor, RGBColor } from "../../models/color.model.mjs";
2
2
  //#region src/color/space/hsl.d.ts
3
3
  export declare function getColorFromHsl<Type extends ColorType>(state: ColorState, type: Type): NonNullable<ColorState[Type]>;
4
4
  export declare function getHslValue(this: InternalColor): HSLColor;
@@ -1,4 +1,4 @@
1
- import { ColorState, ColorType, HSLAColor, HSLColor, HWBAColor, HWBColor, InternalColor, RGBAColor, RGBColor } from "../models.mjs";
1
+ import { ColorState, ColorType, HSLAColor, HSLColor, HWBAColor, HWBColor, InternalColor, RGBAColor, RGBColor } from "../../models/color.model.mjs";
2
2
  //#region src/color/space/hwb.d.ts
3
3
  export declare function convertHwbToHsl(input: HWBAColor | HWBColor): HSLAColor;
4
4
  export declare function getColorFromHwb<Type extends ColorType>(state: ColorState, type: Type): NonNullable<ColorState[Type]>;
@@ -1,4 +1,4 @@
1
- import { ColorState, ColorType, HSLAColor, HSLColor, HWBAColor, HWBColor, InternalColor, RGBAColor, RGBColor } from "../models.mjs";
1
+ import { ColorState, ColorType, HSLAColor, HSLColor, HWBAColor, HWBColor, InternalColor, RGBAColor, RGBColor } from "../../models/color.model.mjs";
2
2
  //#region src/color/space/rgb.d.ts
3
3
  export declare function convertRgbToHex(rgb: RGBAColor | RGBColor, alpha: boolean): string;
4
4
  export declare function convertRgbToHsla(value: unknown): HSLAColor;
@@ -1,5 +1,5 @@
1
- import { GenericAsyncCallback, GenericCallback } from "../models.mjs";
2
- import { AsyncLimiter, Limiter } from "../internal/function/limit.mjs";
1
+ import { GenericAsyncCallback, GenericCallback } from "../models/index.mjs";
2
+ import { AsyncLimiter, Limiter } from "../models/function/limiter.model.mjs";
3
3
  //#region src/function/limit.d.ts
4
4
  /**
5
5
  * Debounce a function, ensuring it is only called after `time` milliseconds have passed
@@ -1,4 +1,5 @@
1
- import { LIMITER_DEBOUNCE, LIMITER_THROTTLE, getAsyncLimiter, getLimiter } from "../internal/function/limit.mjs";
1
+ import { LIMITER_DEBOUNCE, LIMITER_THROTTLE } from "../models/function/limiter.model.mjs";
2
+ import { getAsyncLimiter, getLimiter } from "../internal/function/limit.mjs";
2
3
  //#region src/function/limit.ts
3
4
  /**
4
5
  * Debounce a function, ensuring it is only called after `time` milliseconds have passed
@@ -1,5 +1,8 @@
1
- import { GenericAsyncCallback, GenericCallback, Once, OnceAsync } from "../models.mjs";
1
+ import { GenericAsyncCallback, GenericCallback } from "../models/index.mjs";
2
+ import { AsyncOnce, Once } from "../models/function/once.model.mjs";
2
3
  //#region src/function/once.d.ts
4
+ declare function AsyncOnce(this: any, callback: GenericAsyncCallback): void;
5
+ declare function Once(this: any, callback: GenericCallback): void;
3
6
  /**
4
7
  * Create an asynchronous function that can only be called once, rejecting or resolving the same result on subsequent calls
5
8
  *
@@ -8,7 +11,7 @@ import { GenericAsyncCallback, GenericCallback, Once, OnceAsync } from "../model
8
11
  * @param callback Callback to use once
9
12
  * @returns _Once_ callback
10
13
  */
11
- export declare function asyncOnce<Callback extends GenericAsyncCallback>(callback: Callback): OnceAsync<Callback>;
14
+ export declare function asyncOnce<Callback extends GenericAsyncCallback>(callback: Callback): AsyncOnce<Callback>;
12
15
  /**
13
16
  * Is the value an asynchronous once callback?
14
17
  *
@@ -38,4 +41,5 @@ export declare namespace once {
38
41
  export var is: typeof isOnce;
39
42
  export var isAsync: typeof isAsyncOnce;
40
43
  }
41
- //#endregion
44
+ //#endregion
45
+ export type { AsyncOnce, Once };
@@ -1,8 +1,6 @@
1
1
  import { assert } from "../internal/function/assert.mjs";
2
+ import { ONCE_MESSAGE_CLEARED, ONCE_MESSAGE_EXPECTATION, ONCE_NAME_ASYNC, ONCE_NAME_SYNC, ONCE_PROPERTY, ONCE_SYMBOL } from "../models/function/once.model.mjs";
2
3
  //#region src/function/once.ts
3
- const ONCE_NAME_ASYNC = "asyncOnce";
4
- const ONCE_NAME_SYNC = "once";
5
- const ONCE_PROPERTY = "$once";
6
4
  function AsyncOnce(callback) {
7
5
  this[ONCE_SYMBOL] = {
8
6
  callback,
@@ -94,9 +92,9 @@ function handleOnceResult(state, value, error) {
94
92
  const items = state.items.splice(0);
95
93
  const { length } = items;
96
94
  for (let index = 0; index < length; index += 1) {
97
- const { reject, resolve } = items[index];
98
- if (error) reject(value);
99
- else resolve(value);
95
+ const item = items[index];
96
+ if (error) item.reject(value);
97
+ else item.resolve(value);
100
98
  }
101
99
  }
102
100
  /**
@@ -118,7 +116,7 @@ function isOnce(value) {
118
116
  return isOnceInstance(value, ONCE_NAME_SYNC);
119
117
  }
120
118
  function isOnceInstance(value, name) {
121
- return typeof value === "object" && value !== null && ONCE_PROPERTY in value && value[ONCE_PROPERTY] === name;
119
+ return typeof value === "object" && value !== null && "$once" in value && value["$once"] === name;
122
120
  }
123
121
  /**
124
122
  * Create a function that can only be called once, returning the same value on subsequent calls
@@ -161,9 +159,6 @@ function runOnceAsync(...parameters) {
161
159
  });
162
160
  });
163
161
  }
164
- const ONCE_MESSAGE_CLEARED = "Once has been cleared";
165
- const ONCE_MESSAGE_EXPECTATION = "Once expected a function";
166
- const ONCE_SYMBOL = Symbol(ONCE_PROPERTY);
167
162
  asyncOnce.is = isAsyncOnce;
168
163
  once.async = asyncOnce;
169
164
  once.is = isOnce;
@@ -1,17 +1,6 @@
1
- import { GenericAsyncCallback, GenericCallback } from "../models.mjs";
1
+ import { GenericAsyncCallback, GenericCallback } from "../models/index.mjs";
2
+ import { RetryError, RetryOptions } from "../models/function/retry.model.mjs";
2
3
  //#region src/function/retry.d.ts
3
- /**
4
- * An error thrown when a retry fails
5
- */
6
- export declare class RetryError extends Error {
7
- readonly original: unknown;
8
- constructor(message: string, original: unknown);
9
- }
10
- export type RetryOptions = {
11
- delay?: number;
12
- times?: number;
13
- when?: (error: unknown) => boolean;
14
- };
15
4
  /**
16
5
  * Retry a callback a specified number of times, with a delay between attempts
17
6
  *
@@ -43,4 +32,5 @@ export declare function retry<Callback extends GenericCallback>(callback: Callba
43
32
  export declare namespace retry {
44
33
  export var async: typeof asyncRetry;
45
34
  }
46
- //#endregion
35
+ //#endregion
36
+ export { RetryError };
@@ -1,20 +1,11 @@
1
1
  import { isPlainObject } from "../internal/is.mjs";
2
2
  import { asyncAttempt, attempt } from "../internal/result/attempt.mjs";
3
+ import { LIMITER_WAIT } from "../models/function/limiter.model.mjs";
3
4
  import { getNumberOrDefault } from "../internal/defaults.mjs";
4
- import { LIMITER_WAIT, getLimiter } from "../internal/function/limit.mjs";
5
+ import { getLimiter } from "../internal/function/limit.mjs";
6
+ import { RETRY_MESSAGE_EXPECTATION, RETRY_MESSAGE_FAILED, RetryError } from "../models/function/retry.model.mjs";
5
7
  //#region src/function/retry.ts
6
8
  /**
7
- * An error thrown when a retry fails
8
- */
9
- var RetryError = class extends Error {
10
- original;
11
- constructor(message, original) {
12
- super(message);
13
- this.original = original;
14
- this.name = RETRY_ERROR_NAME;
15
- }
16
- };
17
- /**
18
9
  * Retry a callback a specified number of times, with a delay between attempts
19
10
  *
20
11
  * _Available as `asyncRetry` and `retry.async`_
@@ -77,9 +68,6 @@ function retry(callback, options) {
77
68
  function shouldRetry() {
78
69
  return true;
79
70
  }
80
- const RETRY_ERROR_NAME = "RetryError";
81
- const RETRY_MESSAGE_EXPECTATION = "Retry expected a function";
82
- const RETRY_MESSAGE_FAILED = "Retry failed";
83
71
  retry.async = asyncRetry;
84
72
  //#endregion
85
73
  export { RetryError, retry };
package/dist/herald.d.mts CHANGED
@@ -1,3 +1,3 @@
1
- import { Herald, HeraldEvents } from "./internal/models/herald.model.mjs";
1
+ import { Herald, HeraldEvents, HeraldOptions } from "./models/herald.model.mjs";
2
2
  import { herald, isHerald, isHeraldEvents, isHeraldSubscription } from "./internal/herald.mjs";
3
- export { type Herald, type HeraldEvents, herald, isHerald, isHeraldEvents, isHeraldSubscription };
3
+ export { type Herald, type HeraldEvents, type HeraldOptions, herald, isHerald, isHeraldEvents, isHeraldSubscription };