@oscarpalmer/atoms 0.193.1 → 0.194.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 (79) hide show
  1. package/dist/array/difference.mjs +2 -2
  2. package/dist/array/intersection.mjs +2 -2
  3. package/dist/array/match.mjs +13 -13
  4. package/dist/array/slice.mjs +5 -5
  5. package/dist/array/sort.d.mts +5 -1
  6. package/dist/array/sort.mjs +4 -2
  7. package/dist/array/union.mjs +2 -2
  8. package/dist/beacon.d.mts +8 -1
  9. package/dist/beacon.mjs +52 -60
  10. package/dist/color/constants.d.mts +1 -1
  11. package/dist/color/constants.mjs +3 -5
  12. package/dist/color/instance.mjs +34 -41
  13. package/dist/color/misc/format.d.mts +3 -2
  14. package/dist/color/misc/format.mjs +4 -1
  15. package/dist/color/misc/is.d.mts +9 -1
  16. package/dist/color/misc/is.mjs +11 -1
  17. package/dist/color/misc/state.d.mts +6 -6
  18. package/dist/color/misc/state.mjs +11 -14
  19. package/dist/color/models.d.mts +23 -68
  20. package/dist/function/assert.mjs +2 -2
  21. package/dist/function/limit.d.mts +0 -6
  22. package/dist/function/limit.mjs +2 -2
  23. package/dist/function/memoize.mjs +19 -32
  24. package/dist/function/once.d.mts +0 -3
  25. package/dist/function/once.mjs +16 -13
  26. package/dist/function/retry.d.mts +1 -24
  27. package/dist/function/retry.mjs +1 -1
  28. package/dist/function/work.mjs +13 -11
  29. package/dist/herald.d.mts +30 -31
  30. package/dist/herald.mjs +74 -56
  31. package/dist/index.d.mts +100 -185
  32. package/dist/index.mjs +680 -702
  33. package/dist/internal/abort.d.mts +10 -0
  34. package/dist/internal/abort.mjs +14 -0
  35. package/dist/internal/array/chunk.mjs +2 -2
  36. package/dist/internal/array/find.mjs +2 -2
  37. package/dist/internal/array/sets.d.mts +4 -4
  38. package/dist/internal/array/sets.mjs +7 -7
  39. package/dist/internal/function/timer.mjs +19 -15
  40. package/dist/internal/number.mjs +7 -7
  41. package/dist/internal/result.mjs +3 -3
  42. package/dist/internal/sized.mjs +4 -4
  43. package/dist/internal/string.mjs +4 -4
  44. package/dist/internal/subscription.d.mts +24 -8
  45. package/dist/internal/subscription.mjs +49 -36
  46. package/dist/internal/value/equal.mjs +6 -6
  47. package/dist/internal/value/misc.mjs +14 -14
  48. package/dist/internal/value/set.mjs +2 -2
  49. package/dist/logger.mjs +15 -39
  50. package/dist/promise/constants.d.mts +17 -0
  51. package/dist/promise/constants.mjs +14 -0
  52. package/dist/promise/delay.mjs +7 -10
  53. package/dist/promise/helpers.mjs +1 -1
  54. package/dist/promise/index.mjs +14 -17
  55. package/dist/promise/misc.d.mts +2 -1
  56. package/dist/promise/misc.mjs +8 -7
  57. package/dist/promise/models.d.mts +4 -16
  58. package/dist/promise/models.mjs +4 -13
  59. package/dist/promise/timed.mjs +9 -10
  60. package/dist/query.mjs +15 -15
  61. package/dist/queue.mjs +103 -116
  62. package/dist/random.mjs +7 -7
  63. package/dist/result/index.d.mts +0 -3
  64. package/dist/result/index.mjs +1 -1
  65. package/dist/result/match.d.mts +0 -3
  66. package/dist/result/match.mjs +4 -4
  67. package/dist/result/misc.mjs +2 -2
  68. package/dist/result/work/flow.d.mts +0 -3
  69. package/dist/result/work/flow.mjs +5 -5
  70. package/dist/result/work/pipe.d.mts +0 -3
  71. package/dist/result/work/pipe.mjs +3 -3
  72. package/dist/string/case.mjs +20 -20
  73. package/dist/string/fuzzy.mjs +23 -18
  74. package/dist/string/index.mjs +7 -7
  75. package/dist/string/normalize.mjs +14 -14
  76. package/dist/string/template.mjs +2 -2
  77. package/dist/value/clone.mjs +10 -10
  78. package/dist/value/smush.mjs +2 -2
  79. package/package.json +13 -4
package/dist/herald.mjs CHANGED
@@ -1,64 +1,61 @@
1
- import { noop } from "./internal/function/misc.mjs";
1
+ import { isPlainObject } from "./internal/is.mjs";
2
+ import { createSubscriptions, isSubscription } from "./internal/subscription.mjs";
2
3
  //#region src/herald.ts
3
- function getEvents(herald) {
4
- const events = {
5
- subscribe: (event, callback) => herald.subscribe(event, callback),
6
- unsubscribe: (event, callback) => herald.unsubscribe(event, callback)
7
- };
8
- Object.defineProperty(events, KEY_HERALD, {
9
- enumerable: false,
10
- value: NAME_EVENTS
11
- });
4
+ function createEvents(herald, state) {
5
+ const events = {};
6
+ Object.defineProperty(events, HERALD_PROPERTY, { value: HERALD_NAME_EVENTS });
7
+ for (const key of state.keys) events[key] = (callback, signal) => herald.subscribe(key, callback, signal);
12
8
  return Object.freeze(events);
13
9
  }
10
+ function emitForHerald(state, event, ...parameters) {
11
+ const items = state.subscriptions.state.values.from.keyed?.get(event);
12
+ if (items == null || items.size === 0) return;
13
+ for (const [callback] of items) callback(...parameters);
14
+ }
15
+ function getHeraldSubscriptionProperty(input) {
16
+ if (input == null) return heraldSubscription;
17
+ const property = isPlainObject(input) ? input : {};
18
+ if (typeof property.key !== "string" || property.value != null && typeof property.value !== "string") throw new Error(HERALD_MESSAGE_PROPERTY);
19
+ return {
20
+ key: property.key,
21
+ value: property.value
22
+ };
23
+ }
24
+ function getHeraldState(input) {
25
+ const options = isPlainObject(input) ? input : {};
26
+ if (!Array.isArray(options.names) || options.names.length === 0 || !options.names.every((name) => typeof name === "string")) throw new Error(HERALD_MESSAGE_ARRAY);
27
+ if (options.onCreate != null && typeof options.onCreate !== "function") throw new Error(HERALD_MESSAGE_ONCREATE);
28
+ const keys = new Set(options.names);
29
+ const property = getHeraldSubscriptionProperty(options.property);
30
+ return {
31
+ keys,
32
+ subscriptions: createSubscriptions({
33
+ keys,
34
+ property
35
+ }),
36
+ onCreate: options.onCreate
37
+ };
38
+ }
14
39
  /**
15
40
  * Create a _Herald_ for announcing named events
16
41
  *
17
42
  * @param names Event names
43
+ * @param property Optional property for subscription identification _(defaults to `$herald`)_
18
44
  * @returns _Herald_ instance
19
45
  */
20
- function herald(names) {
21
- if (!Array.isArray(names) || names.length === 0 || !names.every((name) => typeof name === "string")) throw new Error(MESSAGE);
22
- const set = new Set(names);
23
- const subscribers = /* @__PURE__ */ new Map();
46
+ function herald(options) {
47
+ const state = getHeraldState(options);
24
48
  const instance = {
25
- clear() {
26
- subscribers.clear();
27
- },
28
- emit(event, ...parameters) {
29
- const callbacks = subscribers.get(event);
30
- if (callbacks == null) return;
31
- for (const callback of callbacks) callback(...parameters);
32
- },
33
- subscribe(event, callback) {
34
- if (!set.has(event) || typeof callback !== "function") return noop;
35
- let eventSubscribers = subscribers.get(event);
36
- if (eventSubscribers == null) {
37
- eventSubscribers = /* @__PURE__ */ new Set();
38
- subscribers.set(event, eventSubscribers);
39
- }
40
- eventSubscribers.add(callback);
41
- return () => {
42
- eventSubscribers?.delete(callback);
43
- };
44
- },
45
- unsubscribe(event, callback) {
46
- if (!set.has(event) || (callback != null ? typeof callback !== "function" : false)) return;
47
- const eventSubscribers = subscribers.get(event);
48
- if (eventSubscribers == null) return;
49
- if (callback == null) eventSubscribers.clear();
50
- else eventSubscribers.delete(callback);
51
- if (callback == null || eventSubscribers.size === 0) subscribers.delete(event);
52
- }
49
+ clear: () => state.subscriptions.clear(),
50
+ emit: (event, ...parameters) => emitForHerald(state, event, ...parameters),
51
+ observed: (event) => (state.subscriptions.state.items.keyed?.get(event)?.size ?? 0) > 0,
52
+ subscribe: (key, callback, signal) => subscribeToHerald(state, key, callback, signal)
53
53
  };
54
54
  Object.defineProperties(instance, {
55
- [KEY_HERALD]: {
56
- enumerable: false,
57
- value: NAME_HERALD
58
- },
55
+ [HERALD_PROPERTY]: { value: HERALD_NAME_HERALD },
59
56
  events: {
60
57
  enumerable: true,
61
- value: getEvents(instance)
58
+ value: createEvents(instance, state)
62
59
  }
63
60
  });
64
61
  return Object.freeze(instance);
@@ -69,8 +66,8 @@ function herald(names) {
69
66
  * @param value Value to check
70
67
  * @returns `true` if the value is events for a herald, otherwise `false`
71
68
  */
72
- function isEvents(value) {
73
- return isHeraldInstance(NAME_EVENTS, value);
69
+ function isHeraldEvents(value) {
70
+ return isHeraldInstance(HERALD_NAME_EVENTS, value);
74
71
  }
75
72
  /**
76
73
  * Is the value a herald?
@@ -79,14 +76,35 @@ function isEvents(value) {
79
76
  * @returns `true` if the value is a herald, otherwise `false`
80
77
  */
81
78
  function isHerald(value) {
82
- return isHeraldInstance(NAME_HERALD, value);
79
+ return isHeraldInstance(HERALD_NAME_HERALD, value);
83
80
  }
84
81
  function isHeraldInstance(name, value) {
85
- return typeof value === "object" && value != null && KEY_HERALD in value && value[KEY_HERALD] === name;
82
+ return isPlainObject(value) && HERALD_PROPERTY in value && value[HERALD_PROPERTY] === name;
83
+ }
84
+ /**
85
+ * Is the value a herald subscription?
86
+ *
87
+ * @param value Value to check
88
+ * @returns `true` if the value is a herald subscription, otherwise `false`
89
+ */
90
+ function isHeraldSubscription(value) {
91
+ return isSubscription(value) && value[HERALD_PROPERTY] === "subscription";
92
+ }
93
+ function subscribeToHerald(state, key, callback, signal) {
94
+ const [subscription, existing] = state.subscriptions.create({
95
+ key,
96
+ signal,
97
+ value: callback
98
+ });
99
+ if (!existing) state.onCreate?.(key, callback, subscription);
100
+ return subscription;
86
101
  }
87
- const KEY_HERALD = "$herald";
88
- const MESSAGE = "Herald requires an array of event names.";
89
- const NAME_EVENTS = "events";
90
- const NAME_HERALD = "herald";
102
+ const HERALD_PROPERTY = "$herald";
103
+ const HERALD_MESSAGE_ARRAY = "Herald requires an array of event names.";
104
+ const HERALD_MESSAGE_ONCREATE = `Herald requires a valid onCreate callback for subscription creation`;
105
+ const HERALD_MESSAGE_PROPERTY = `Herald requires valid property information for subscription identification`;
106
+ const HERALD_NAME_EVENTS = "events";
107
+ const HERALD_NAME_HERALD = "herald";
108
+ const heraldSubscription = { key: HERALD_PROPERTY };
91
109
  //#endregion
92
- export { herald, isEvents, isHerald };
110
+ export { herald, isHerald, isHeraldEvents, isHeraldSubscription };
package/dist/index.d.mts CHANGED
@@ -2890,6 +2890,10 @@ type ArrayKeySorters<Item extends PlainObject> = { [ItemKey in keyof Item]: Arra
2890
2890
  * Sorter to use for sorting
2891
2891
  */
2892
2892
  type ArraySorter<Item> = Item extends PlainObject ? keyof Item | ArrayComparisonSorter<Item> | ArrayKeySorters<Item> | ArrayValueSorter<Item> | ComparisonSorter<Item> : ArrayComparisonSorter<Item> | ArrayValueSorter<Item> | ComparisonSorter<Item>;
2893
+ /**
2894
+ * Sorters to use for sorting
2895
+ */
2896
+ type ArraySorters<Item> = Array<ArraySorter<Item>>;
2893
2897
  /**
2894
2898
  * Sorting information for arrays _(using a value callback and built-in comparison)_
2895
2899
  */
@@ -3984,9 +3988,6 @@ declare function asyncThrottle<Callback extends GenericAsyncCallback | GenericCa
3984
3988
  * @returns Debounced callback handler with a `cancel` method
3985
3989
  */
3986
3990
  declare function debounce<Callback extends GenericCallback>(callback: Callback, time?: number): CancelableCallback<Callback>;
3987
- declare namespace debounce {
3988
- var async: typeof asyncDebounce;
3989
- }
3990
3991
  /**
3991
3992
  * Throttle a function, ensuring it is only called once every `time` milliseconds
3992
3993
  *
@@ -3995,9 +3996,6 @@ declare namespace debounce {
3995
3996
  * @returns Throttled callback handler with a `cancel` method
3996
3997
  */
3997
3998
  declare function throttle<Callback extends GenericCallback>(callback: Callback, time?: number): CancelableCallback<Callback>;
3998
- declare namespace throttle {
3999
- var async: typeof asyncThrottle;
4000
- }
4001
3999
  //#endregion
4002
4000
  //#region src/function/once.d.ts
4003
4001
  /**
@@ -4016,9 +4014,6 @@ declare function asyncOnce<Callback extends GenericAsyncCallback>(callback: Call
4016
4014
  * @returns _Once_ callback
4017
4015
  */
4018
4016
  declare function once<Callback extends GenericCallback>(callback: Callback): OnceCallback<Callback>;
4019
- declare namespace once {
4020
- var async: typeof asyncOnce;
4021
- }
4022
4017
  //#endregion
4023
4018
  //#region src/function/retry.d.ts
4024
4019
  /**
@@ -4033,26 +4028,6 @@ type RetryOptions = {
4033
4028
  times?: number;
4034
4029
  when?: (error: unknown) => boolean;
4035
4030
  };
4036
- /**
4037
- * Retry a callback a specified number of times, with a delay between attempts
4038
- *
4039
- * _Available as `asyncRetry` and `retry.async`_
4040
- *
4041
- * @param callback Callback to retry
4042
- * @param options Retry options
4043
- * @returns Callback result
4044
- */
4045
- declare function asyncRetry<Callback extends GenericAsyncCallback>(callback: Callback, options?: RetryOptions): Promise<Awaited<ReturnType<Callback>>>;
4046
- /**
4047
- * Retry a callback a specified number of times, with a delay between attempts
4048
- *
4049
- * _Available as `asyncRetry` and `retry.async`_
4050
- *
4051
- * @param callback Callback to retry
4052
- * @param options Retry options
4053
- * @returns Callback result
4054
- */
4055
- declare function asyncRetry<Callback extends GenericCallback>(callback: Callback, options?: RetryOptions): Promise<ReturnType<Callback>>;
4056
4031
  /**
4057
4032
  * Retry a callback a specified number of times
4058
4033
  *
@@ -4061,9 +4036,6 @@ declare function asyncRetry<Callback extends GenericCallback>(callback: Callback
4061
4036
  * @returns Callback result
4062
4037
  */
4063
4038
  declare function retry<Callback extends GenericCallback>(callback: Callback, options?: Omit<RetryOptions, 'delay'>): ReturnType<Callback>;
4064
- declare namespace retry {
4065
- var async: typeof asyncRetry;
4066
- }
4067
4039
  //#endregion
4068
4040
  //#region src/result/models.d.ts
4069
4041
  /**
@@ -4503,27 +4475,41 @@ declare namespace pipe {
4503
4475
  var async: typeof asyncPipe;
4504
4476
  }
4505
4477
  //#endregion
4506
- //#region src/herald.d.ts
4507
- type Events<Map extends Record<string, GenericCallback>> = {
4478
+ //#region src/internal/subscription.d.ts
4479
+ type Subscription = {
4508
4480
  /**
4509
- * Subscribe to an event with a callback
4510
- *
4511
- * @param event Event name
4512
- * @param callback Callback function
4513
- * @returns Unsubscriber function
4481
+ * Is the subscription active?
4514
4482
  */
4515
- subscribe<Event extends keyof Map>(event: Event, callback: Map[Event]): Unsubscriber;
4483
+ get active(): boolean;
4516
4484
  /**
4517
- * Unsubscribe from an event with a callback _(or all callbacks, if no callback is provided)_
4518
- *
4519
- * @param event Event name
4520
- * @param callback Callback function
4521
- * @returns Unsubscriber function
4485
+ * Unsubscribe from changes
4522
4486
  */
4523
- unsubscribe<Event extends keyof Map>(event: Event, callback?: Map[Event]): void;
4487
+ unsubscribe(): void;
4488
+ };
4489
+ /**
4490
+ * Property information for subscription identification
4491
+ */
4492
+ type SubscriptionProperty = {
4493
+ /**
4494
+ * Name of the property used to identify a subscription
4495
+ */
4496
+ key: string;
4497
+ /**
4498
+ * Value of the property used to identify a subscription _(defaults to `subscription`)_
4499
+ */
4500
+ value?: unknown;
4524
4501
  };
4525
- type Herald<Map extends Record<string, GenericCallback>> = {
4526
- readonly events: Events<Map>;
4502
+ /**
4503
+ * Is the value a subscription?
4504
+ *
4505
+ * @param value Value to check
4506
+ * @returns `true` if the value is a subscription, otherwise `false`
4507
+ */
4508
+ declare function isSubscription(value: unknown): value is Subscription;
4509
+ //#endregion
4510
+ //#region src/herald.d.ts
4511
+ type Herald<Events extends Record<string, GenericCallback>> = {
4512
+ readonly events: HeraldEvents<Events>;
4527
4513
  /**
4528
4514
  * Remove all event subscribers
4529
4515
  */
@@ -4534,37 +4520,46 @@ type Herald<Map extends Record<string, GenericCallback>> = {
4534
4520
  * @param event Event name
4535
4521
  * @param parameters Event parameters
4536
4522
  */
4537
- emit<Event extends keyof Map>(event: Event, ...parameters: Parameters<Map[Event]>): void;
4523
+ emit<Event extends keyof Events>(event: Event, ...parameters: Parameters<Events[Event]>): void;
4538
4524
  /**
4539
- * Subscribe to an event with a callback
4525
+ * Is the event observed by any subscribers?
4540
4526
  *
4541
4527
  * @param event Event name
4542
- * @param callback Callback function
4543
- * @returns Unsubscriber function
4528
+ * @returns `true` if the event is observed, otherwise `false`
4544
4529
  */
4545
- subscribe<Event extends keyof Map>(event: Event, callback: Map[Event]): Unsubscriber;
4530
+ observed<Event extends keyof Events>(event: Event): boolean;
4546
4531
  /**
4547
- * Unsubscribe from an event with a callback _(or all callbacks, if no callback is provided)_
4532
+ * Subscribe to an event with a callback
4548
4533
  *
4549
4534
  * @param event Event name
4550
4535
  * @param callback Callback function
4536
+ * @param signal Optional abort signal to cancel the subscription
4537
+ * @returns Subscription instance
4551
4538
  */
4552
- unsubscribe<Event extends keyof Map>(event: Event, callback?: Map[Event]): void;
4539
+ subscribe<Event extends keyof Events>(event: Event, callback: Events[Event], signal?: AbortSignal): Subscription;
4540
+ };
4541
+ type HeraldEvents<Events extends Record<string, GenericCallback>> = { [Key in keyof Events]: Key extends '*' ? never : (callback: Events[Key], signal?: AbortSignal) => void; };
4542
+ type HeraldOnCreate<Events extends Record<string, GenericCallback>> = <Event extends keyof Events>(event: Event, callback: Events[Event], subscription: Subscription) => void;
4543
+ type HeraldOptions<Events extends Record<string, GenericCallback>> = {
4544
+ names: Array<keyof Events>;
4545
+ property?: SubscriptionProperty;
4546
+ onCreate?: HeraldOnCreate<Events>;
4553
4547
  };
4554
4548
  /**
4555
4549
  * Create a _Herald_ for announcing named events
4556
4550
  *
4557
4551
  * @param names Event names
4552
+ * @param property Optional property for subscription identification _(defaults to `$herald`)_
4558
4553
  * @returns _Herald_ instance
4559
4554
  */
4560
- declare function herald<Events extends Record<string, GenericCallback>>(names: (keyof Events)[]): Herald<Events>;
4555
+ declare function herald<Events extends Record<string, GenericCallback>>(options: HeraldOptions<Events>): Herald<Events>;
4561
4556
  /**
4562
4557
  * Is the value events for a herald?
4563
4558
  *
4564
4559
  * @param value Value to check
4565
4560
  * @returns `true` if the value is events for a herald, otherwise `false`
4566
4561
  */
4567
- declare function isEvents<Map extends Record<string, GenericCallback> = Record<string, GenericCallback>>(value: unknown): value is Events<Map>;
4562
+ declare function isHeraldEvents<Events extends Record<string, GenericCallback> = Record<string, GenericCallback>>(value: unknown): value is HeraldEvents<Events>;
4568
4563
  /**
4569
4564
  * Is the value a herald?
4570
4565
  *
@@ -4572,6 +4567,13 @@ declare function isEvents<Map extends Record<string, GenericCallback> = Record<s
4572
4567
  * @returns `true` if the value is a herald, otherwise `false`
4573
4568
  */
4574
4569
  declare function isHerald<Events extends Record<string, GenericCallback> = Record<string, GenericCallback>>(value: unknown): value is Herald<Events>;
4570
+ /**
4571
+ * Is the value a herald subscription?
4572
+ *
4573
+ * @param value Value to check
4574
+ * @returns `true` if the value is a herald subscription, otherwise `false`
4575
+ */
4576
+ declare function isHeraldSubscription(value: unknown): value is Subscription;
4575
4577
  //#endregion
4576
4578
  //#region src/internal/string.d.ts
4577
4579
  /**
@@ -4614,25 +4616,6 @@ declare function tryEncode(value: boolean | number | string): unknown;
4614
4616
  */
4615
4617
  declare function words(value: string): string[];
4616
4618
  //#endregion
4617
- //#region src/internal/subscription.d.ts
4618
- type Subscription = {
4619
- /**
4620
- * Is the subscription active?
4621
- */
4622
- get active(): boolean;
4623
- /**
4624
- * Unsubscribe from changes
4625
- */
4626
- unsubscribe(): void;
4627
- };
4628
- /**
4629
- * Is the value a subscription?
4630
- *
4631
- * @param value Value to check
4632
- * @returns `true` if the value is a subscription, otherwise `false`
4633
- */
4634
- declare function isSubscription(value: unknown): value is Subscription;
4635
- //#endregion
4636
4619
  //#region src/internal/value/compare.d.ts
4637
4620
  type Comparator<Value = any> = (first: Value, second: Value) => number;
4638
4621
  /**
@@ -5957,6 +5940,13 @@ declare function beacon<Value>(value: Value, options?: BeaconOptions<Value>): Be
5957
5940
  * @returns `true` if the value is a beacon, otherwise `false`
5958
5941
  */
5959
5942
  declare function isBeacon<Value = unknown>(value: unknown): value is Beacon<Value>;
5943
+ /**
5944
+ * Is the value a beacon subscription?
5945
+ *
5946
+ * @param value Value to check
5947
+ * @returns `true` if the value is a beacon subscription, otherwise `false`
5948
+ */
5949
+ declare function isBeaconSubscription(value: unknown): value is Subscription;
5960
5950
  /**
5961
5951
  * Is the value an observable?
5962
5952
  *
@@ -5965,25 +5955,15 @@ declare function isBeacon<Value = unknown>(value: unknown): value is Beacon<Valu
5965
5955
  */
5966
5956
  declare function isObservable<Value = unknown>(value: unknown): value is Observable<Value>;
5967
5957
  //#endregion
5968
- //#region src/color/constants.d.ts
5969
- type ColorTypes = {
5970
- all: Set<'alpha' | ColorTypeExtended>;
5971
- hex: 'hex';
5972
- hexa: 'hexa';
5973
- hsl: 'hsl';
5974
- hsla: 'hsla';
5975
- hwb: 'hwb';
5976
- hwba: 'hwba';
5977
- rgb: 'rgb';
5978
- rgba: 'rgba';
5979
- };
5980
- declare const COLOR_TYPE: ColorTypes;
5981
- //#endregion
5982
5958
  //#region src/color/models.d.ts
5983
5959
  /**
5984
5960
  * A color that is represented in multiple color formats
5985
5961
  */
5986
5962
  type Color = {
5963
+ /**
5964
+ *
5965
+ */
5966
+ readonly changes: HeraldEvents<ColorChanges>;
5987
5967
  /**
5988
5968
  * Get the alpha channel _(opacity)_ of the color as a percentage between `0` and `100`
5989
5969
  *
@@ -6109,74 +6089,12 @@ type Color = {
6109
6089
  */
6110
6090
  set rgba(value: RGBAColor);
6111
6091
  /**
6112
- * Subscribe to alpha channel _(opacity)_ changes of the color
6113
- *
6114
- * @param key Color property to subscribe to
6115
- * @param callback Callback function for changes
6116
- */
6117
- subscribe(key: 'alpha', callback: (value: number) => void): Subscription;
6118
- /**
6119
- * Subscribe to hex color changes of the color
6092
+ * Subscribe to value changes for the color
6120
6093
  *
6121
- * @param key Color type to subscribe to
6122
- * @param callback Callback function for changes
6123
- */
6124
- subscribe(key: typeof COLOR_TYPE.hex, callback: (value: string) => void): Subscription;
6125
- /**
6126
- * Subscribe to hex color changes of the color with alpha channel _(opacity)_
6127
- *
6128
- * @param key Color type to subscribe to
6129
- * @param callback Callback function for changes
6130
- */
6131
- subscribe(key: typeof COLOR_TYPE.hexa, callback: (value: string) => void): Subscription;
6132
- /**
6133
- * Subscribe to _HSL_ color changes of the color
6134
- *
6135
- * @param key Color type to subscribe to
6136
- * @param callback Callback function for changes
6137
- */
6138
- subscribe(key: typeof COLOR_TYPE.hsl, callback: (value: HSLColor) => void): Subscription;
6139
- /**
6140
- * Subscribe to _HSL(A)_ color changes of the color
6141
- *
6142
- * @param key Color type to subscribe to
6143
- * @param callback Callback function for changes
6144
- */
6145
- subscribe(key: typeof COLOR_TYPE.hsla, callback: (value: HSLAColor) => void): Subscription;
6146
- /**
6147
- * Subscribe to _HWB_ color changes of the color
6148
- *
6149
- * @param key Color type to subscribe to
6150
- * @param callback Callback function for changes
6151
- */
6152
- subscribe(key: typeof COLOR_TYPE.hwb, callback: (value: HWBColor) => void): Subscription;
6153
- /**
6154
- * Subscribe to _HWB(A)_ color changes of the color
6155
- *
6156
- * @param key Color type to subscribe to
6157
- * @param callback Callback function for changes
6158
- */
6159
- subscribe(key: typeof COLOR_TYPE.hwba, callback: (value: HWBAColor) => void): Subscription;
6160
- /**
6161
- * Subscribe to _RGB_ color changes of the color
6162
- *
6163
- * @param key Color type to subscribe to
6164
- * @param callback Callback function for changes
6165
- */
6166
- subscribe(key: typeof COLOR_TYPE.rgb, callback: (value: RGBColor) => void): Subscription;
6167
- /**
6168
- * Subscribe to _RGBA_ color changes of the color
6169
- *
6170
- * @param key Color type to subscribe to
6171
- * @param callback Callback function for changes
6172
- */
6173
- subscribe(key: typeof COLOR_TYPE.rgba, callback: (value: RGBAColor) => void): Subscription;
6174
- /**
6175
- * Subscribe to any color changes of the color
6176
- *
6177
- * @param callback Callback function for changes
6094
+ * @param callback Callback function
6095
+ * @param signal Optional abort signal to cancel the subscription
6178
6096
  */
6179
- subscribe(callback: (value: Color) => void): Subscription;
6097
+ subscribe(callback: (value: Color) => void, signal?: AbortSignal): Subscription;
6180
6098
  /**
6181
6099
  * Get the color as a hex string
6182
6100
  *
@@ -6218,6 +6136,18 @@ type Color = {
6218
6136
  */
6219
6137
  unsubscribe(): void;
6220
6138
  };
6139
+ type ColorChanges = {
6140
+ '*': (value: Color) => void;
6141
+ alpha: (value: number) => void;
6142
+ hex: (value: string) => void;
6143
+ hexa: (value: string) => void;
6144
+ hsl: (value: HSLColor) => void;
6145
+ hsla: (value: HSLAColor) => void;
6146
+ hwb: (value: HWBColor) => void;
6147
+ hwba: (value: HWBAColor) => void;
6148
+ rgb: (value: RGBColor) => void;
6149
+ rgba: (value: RGBAColor) => void;
6150
+ };
6221
6151
  type ColorWithAlpha = {
6222
6152
  /**
6223
6153
  * Alpha channel _(opacity)_ of the color _(in percentage; 0-100)_
@@ -7213,6 +7143,17 @@ declare function clamp(value: number, minimum: number, maximum: number, loop?: b
7213
7143
  */
7214
7144
  declare function getNumber(value: unknown): number;
7215
7145
  //#endregion
7146
+ //#region src/internal/abort.d.ts
7147
+ type Aborter = {
7148
+ callback: GenericCallback;
7149
+ signal: AbortSignal;
7150
+ cancel: () => void;
7151
+ };
7152
+ //#endregion
7153
+ //#region src/promise/constants.d.ts
7154
+ declare const PROMISE_TYPE_FULFILLED = "fulfilled";
7155
+ declare const PROMISE_TYPE_REJECTED = "rejected";
7156
+ //#endregion
7216
7157
  //#region src/promise/models.d.ts
7217
7158
  /**
7218
7159
  * A _Promise_ that can be canceled
@@ -7262,12 +7203,11 @@ type PromiseOptions = {
7262
7203
  time?: number;
7263
7204
  };
7264
7205
  type PromiseParameters = {
7265
- abort: () => void;
7206
+ aborter?: Aborter;
7266
7207
  complete: boolean;
7267
7208
  data: PromiseData;
7268
7209
  handlers: PromiseHandlers;
7269
7210
  index: number;
7270
- signal?: AbortSignal;
7271
7211
  value?: unknown;
7272
7212
  };
7273
7213
  /**
@@ -7314,19 +7254,6 @@ type RejectedPromise = {
7314
7254
  */
7315
7255
  reason: unknown;
7316
7256
  };
7317
- declare const PROMISE_ABORT_EVENT = "abort";
7318
- declare const PROMISE_ABORT_OPTIONS: {
7319
- once: boolean;
7320
- };
7321
- declare const PROMISE_ERROR_NAME = "PromiseTimeoutError";
7322
- declare const PROMISE_MESSAGE_EXPECTATION_ATTEMPT = "Attempt expected a function or a promise";
7323
- declare const PROMISE_MESSAGE_EXPECTATION_RESULT = "toResult expected a Promise";
7324
- declare const PROMISE_MESSAGE_EXPECTATION_TIMED = "Timed function expected a Promise";
7325
- declare const PROMISE_MESSAGE_TIMEOUT = "Promise timed out";
7326
- declare const PROMISE_STRATEGY_ALL: Set<PromiseStrategy>;
7327
- declare const PROMISE_STRATEGY_DEFAULT: PromiseStrategy;
7328
- declare const PROMISE_TYPE_FULFILLED = "fulfilled";
7329
- declare const PROMISE_TYPE_REJECTED = "rejected";
7330
7257
  //#endregion
7331
7258
  //#region src/promise/delay.d.ts
7332
7259
  /**
@@ -7581,7 +7508,7 @@ declare function isRejected(value: unknown): value is RejectedPromise;
7581
7508
  */
7582
7509
  declare function cancelable<Value>(executor: (resolve: (value: Value) => void, reject: (reason: unknown) => void) => void): CancelablePromise<Value>;
7583
7510
  declare function handleResult(status: string, parameters: PromiseParameters): void;
7584
- declare function settlePromise(aborter: () => void, settler: (value: any) => void, value: unknown, signal?: AbortSignal): void;
7511
+ declare function settlePromise(settler: (value: any) => void, value: unknown, aborter?: Aborter): void;
7585
7512
  /**
7586
7513
  * Converts a _Promise_ to a promised result
7587
7514
  *
@@ -8003,9 +7930,6 @@ declare function attempt<Value, E>(callback: () => Value, error: E): ExtendedRes
8003
7930
  * @returns Callback result
8004
7931
  */
8005
7932
  declare function attempt<Value>(callback: () => Value): Result<Value, Error>;
8006
- declare namespace attempt {
8007
- var async: typeof asyncAttempt;
8008
- }
8009
7933
  //#endregion
8010
7934
  //#region src/result/match.d.ts
8011
7935
  /**
@@ -8046,9 +7970,6 @@ declare function matchResult<Value, Returned, E = Error>(result: AnyResult<Value
8046
7970
  * @returns Matched value
8047
7971
  */
8048
7972
  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;
8049
- declare namespace matchResult {
8050
- var async: typeof asyncMatchResult;
8051
- }
8052
7973
  //#endregion
8053
7974
  //#region src/result/work/flow.d.ts
8054
7975
  /**
@@ -8227,9 +8148,6 @@ declare function attemptFlow<First extends GenericCallback>(first: First, ...fns
8227
8148
  * @returns _Flow_ function
8228
8149
  */
8229
8150
  declare function attemptFlow(...fns: GenericCallback[]): (...args: unknown[]) => Result<unknown>;
8230
- declare namespace attemptFlow {
8231
- var async: typeof attemptAsyncFlow;
8232
- }
8233
8151
  //#endregion
8234
8152
  //#region src/result/work/pipe.d.ts
8235
8153
  type WrapValue<Value> = Result<UnwrapValue<Value>>;
@@ -8409,9 +8327,6 @@ declare function attemptPipe<Initial, First, Second, Third, Fourth, Fifth, Sixth
8409
8327
  * @returns _Piped_ result
8410
8328
  */
8411
8329
  declare function attemptPipe<Initial>(initial: GenericCallback | Initial | Result<Initial>, first?: (value: UnwrapValue<Initial>) => unknown, ...seconds: Array<(value: unknown) => unknown>): WrapValue<Initial>;
8412
- declare namespace attemptPipe {
8413
- var async: typeof attemptAsyncPipe;
8414
- }
8415
8330
  //#endregion
8416
8331
  //#region src/sized/map.d.ts
8417
8332
  /**
@@ -8510,4 +8425,4 @@ declare class SizedSet<Value = unknown> extends Set<Value> {
8510
8425
  get(value: Value, update?: boolean): Value | undefined;
8511
8426
  }
8512
8427
  //#endregion
8513
- export { AnyResult, ArrayComparison, ArrayComparisonSorter, ArrayKeySorter, ArrayOrPlainObject, ArrayValueSorter, AssertProperty, Asserter, AssignOptions, Assigner, AsyncCancelableCallback, AttemptFlow, AttemptFlowPromise, Beacon, BeaconOptions, BuiltIns, CancelableCallback, CancelablePromise, type Color, type ColorType, type ColorTypeExtended, type ColorValue, type ColorValueExtended, Constructor, DiffOptions, DiffResult, DiffValue, EqualOptions, Err, EventPosition, Events, ExtendedErr, ExtendedResult, Flow, FlowPromise, Frozen, FulfilledPromise, Fuzzy, FuzzyConfiguration, FuzzyOptions, FuzzyResult, FuzzySearchOptions, GenericAsyncCallback, GenericCallback, type HSLAColor, type HSLColor, type HWBAColor, type HWBColor, Herald, Key$1 as Key, KeyedQueue, KeyedValue, Logger, type Memoized, type MemoizedOptions, MergeOptions, Merger, NestedArray, NestedKeys, NestedPartial, NestedValue, NestedValues, NormalizeOptions, Normalizer, NumericalKeys, NumericalValues, Observable, Ok, OnceAsyncCallback, OnceCallback, PROMISE_ABORT_EVENT, PROMISE_ABORT_OPTIONS, PROMISE_ERROR_NAME, PROMISE_MESSAGE_EXPECTATION_ATTEMPT, PROMISE_MESSAGE_EXPECTATION_RESULT, PROMISE_MESSAGE_EXPECTATION_TIMED, PROMISE_MESSAGE_TIMEOUT, PROMISE_STRATEGY_ALL, PROMISE_STRATEGY_DEFAULT, PROMISE_TYPE_FULFILLED, PROMISE_TYPE_REJECTED, PlainObject, Primitive, PromiseData, PromiseHandlers, PromiseOptions, PromiseParameters, PromiseStrategy, PromiseTimeoutError, PromisesItems, PromisesOptions, PromisesResult, PromisesUnwrapped, PromisesValue, PromisesValues, Queue, QueueError, QueueOptions, Queued, type RGBAColor, type RGBColor, RejectedPromise, RequiredKeys, Result, ResultMatch, RetryError, RetryOptions, SORT_DIRECTION_ASCENDING, SORT_DIRECTION_DESCENDING, type Shaken, Simplify, SizedMap, SizedSet, type Smushed, SortDirection, Sorter, type Subscription, TemplateOptions, type TimedLogger, ToString, Transformer, TypedArray, UnionToIntersection, type Unsmushed, Unsubscriber, UnwrapValue, assert, assertCondition, assertDefined, assertInstanceOf, assertIs, assertProperty, assign, asyncAttempt, asyncDebounce, asyncFlow, asyncMatchResult, asyncOnce, asyncPipe, asyncThrottle, attempt, attemptAsyncFlow, attemptAsyncPipe, attemptFlow, attemptPipe, attemptPromise, average, beacon, between, camelCase, cancelable, capitalize, ceil, chunk, clamp, clone, compact, compare, copy, count, debounce, deburr, dedent, delay, deregisterCloner, deregisterComparator, deregisterEqualizer, diff, difference, drop, endsWith, endsWithArray, equal, error, exclude, exists, filter, find, findLast, first, firstOrDefault, flatFreeze, flatten, floor, flow, freeze, fromQuery, toPromise as fromResult, toPromise, fuzzy, fuzzyMatch, getArray, getArrayComparison, getColor, getError, getForegroundColor, getHexColor, getHexaColor, getHslColor, getHslaColor, getHwbColor, getHwbaColor, getNormalizedHex, getNumber, getRandomBoolean, getRandomCharacters, getRandomColor, getRandomFloatingNumber as getRandomFloat, getRandomHex, getRandomInteger, getRandomItem, getRandomItems, getRgbColor, getRgbaColor, getSortedIndex, getString, getTimedPromise, getUuid, getValue, groupArraysBy, groupBy, handleResult, hasValue, hasValueResult, herald, hexToHsl, hexToHsla, hexToHwb, hexToHwba, hexToRgb, hexToRgba, hslToHex, hslToHwb, hslToHwba, hslToRgb, hslToRgba, hwbToHex, hwbToHsl, hwbToHsla, hwbToRgb, hwbToRgba, ignoreKey, inMap, inSet, includes, includesArray, indexOf, indexOfArray, initializeAssigner, initializeEqualizer, initializeMerger, initializeNormalizer, initializeSorter, initializeTemplater, initializeTransformer, insert, interpolate, intersection, isArrayOrPlainObject, isBeacon, isColor, isConstructor, isEmpty, isError, isEvents, isFrozen, isFulfilled, isHerald, isHexColor, isHslColor, isHslaColor, isHwbColor, isHwbaColor, isInstanceOf, isKey, isKeyedQueue, isLogger, isNonArrayOrPlainObject, isNonConstructor, isNonEmpty, isNonInstanceOf, isNonKey, isNonNullable, isNonNullableOrEmpty, isNonNullableOrWhitespace, isNonNumber, isNonNumerical, isNonObject, isNonPlainObject, isNonPrimitive, isNonTypedArray, isNullable, isNullableOrEmpty, isNullableOrWhitespace, isNumber, isNumerical, isObject, isObservable, isOk, isPlainObject, isPrimitive, isQueue, isQueueInstance, isRejected, isResult, isRgbColor, isRgbaColor, isSorted, isSubscription, isTimedLogger, isTypedArray, join, kebabCase, keyedQueue, last, lastIndexOf, lastOrDefault, lowerCase, matchResult, max, median, memoize, merge, min, move, moveIndices, moveToIndex, noop, normalize, ok, omit, once, parse, partition, pascalCase, pick, pipe, promises, push, queue, range, registerCloner, registerComparator, registerEqualizer, resultPromises, retry, reverse, rgbToHex, rgbToHsl, rgbToHsla, rgbToHwb, rgbToHwba, round, select, setValue, settlePromise, shake, shuffle, single, slice, smush, snakeCase, sort, splice, startsWith, startsWithArray, sum, swap, take, template, throttle, timed, times, titleCase, toMap, toMapArrays, toQuery, toRecord, toRecordArrays, toResult, toSet, toggle, transform, trim, truncate, tryDecode, tryEncode, union, unique, unsmush, unwrap, update, upperCase, words };
8428
+ export { AnyResult, ArrayComparison, ArrayComparisonSorter, ArrayKeySorter, ArrayOrPlainObject, ArraySorter, ArraySorters, ArrayValueSorter, AssertProperty, Asserter, AssignOptions, Assigner, AsyncCancelableCallback, AttemptFlow, AttemptFlowPromise, Beacon, BeaconOptions, BuiltIns, CancelableCallback, CancelablePromise, type Color, type ColorType, type ColorTypeExtended, type ColorValue, type ColorValueExtended, Constructor, DiffOptions, DiffResult, DiffValue, EqualOptions, Err, EventPosition, ExtendedErr, ExtendedResult, Flow, FlowPromise, Frozen, FulfilledPromise, Fuzzy, FuzzyConfiguration, FuzzyOptions, FuzzyResult, FuzzySearchOptions, GenericAsyncCallback, GenericCallback, type HSLAColor, type HSLColor, type HWBAColor, type HWBColor, Herald, HeraldEvents, HeraldOptions, Key$1 as Key, KeyedQueue, KeyedValue, Logger, type Memoized, type MemoizedOptions, MergeOptions, Merger, NestedArray, NestedKeys, NestedPartial, NestedValue, NestedValues, NormalizeOptions, Normalizer, NumericalKeys, NumericalValues, Observable, Ok, OnceAsyncCallback, OnceCallback, PlainObject, Primitive, PromiseData, PromiseHandlers, PromiseOptions, PromiseParameters, PromiseStrategy, PromiseTimeoutError, PromisesItems, PromisesOptions, PromisesResult, PromisesUnwrapped, PromisesValue, PromisesValues, Queue, QueueError, QueueOptions, Queued, type RGBAColor, type RGBColor, RejectedPromise, RequiredKeys, Result, ResultMatch, RetryError, RetryOptions, SORT_DIRECTION_ASCENDING, SORT_DIRECTION_DESCENDING, type Shaken, Simplify, SizedMap, SizedSet, type Smushed, SortDirection, Sorter, type Subscription, TemplateOptions, type TimedLogger, ToString, Transformer, TypedArray, UnionToIntersection, type Unsmushed, Unsubscriber, UnwrapValue, assert, assertCondition, assertDefined, assertInstanceOf, assertIs, assertProperty, assign, asyncAttempt, asyncDebounce, asyncFlow, asyncMatchResult, asyncOnce, asyncPipe, asyncThrottle, attempt, attemptAsyncFlow, attemptAsyncPipe, attemptFlow, attemptPipe, attemptPromise, average, beacon, between, camelCase, cancelable, capitalize, ceil, chunk, clamp, clone, compact, compare, copy, count, debounce, deburr, dedent, delay, deregisterCloner, deregisterComparator, deregisterEqualizer, diff, difference, drop, endsWith, endsWithArray, equal, error, exclude, exists, filter, find, findLast, first, firstOrDefault, flatFreeze, flatten, floor, flow, freeze, fromQuery, toPromise as fromResult, toPromise, fuzzy, fuzzyMatch, getArray, getArrayComparison, getColor, getError, getForegroundColor, getHexColor, getHexaColor, getHslColor, getHslaColor, getHwbColor, getHwbaColor, getNormalizedHex, getNumber, getRandomBoolean, getRandomCharacters, getRandomColor, getRandomFloatingNumber as getRandomFloat, getRandomHex, getRandomInteger, getRandomItem, getRandomItems, getRgbColor, getRgbaColor, getSortedIndex, getString, getTimedPromise, getUuid, getValue, groupArraysBy, groupBy, handleResult, hasValue, hasValueResult, herald, hexToHsl, hexToHsla, hexToHwb, hexToHwba, hexToRgb, hexToRgba, hslToHex, hslToHwb, hslToHwba, hslToRgb, hslToRgba, hwbToHex, hwbToHsl, hwbToHsla, hwbToRgb, hwbToRgba, ignoreKey, inMap, inSet, includes, includesArray, indexOf, indexOfArray, initializeAssigner, initializeEqualizer, initializeMerger, initializeNormalizer, initializeSorter, initializeTemplater, initializeTransformer, insert, interpolate, intersection, isArrayOrPlainObject, isBeacon, isBeaconSubscription, isColor, isConstructor, isEmpty, isError, isFrozen, isFulfilled, isHerald, isHeraldEvents, isHeraldSubscription, isHexColor, isHslColor, isHslaColor, isHwbColor, isHwbaColor, isInstanceOf, isKey, isKeyedQueue, isLogger, isNonArrayOrPlainObject, isNonConstructor, isNonEmpty, isNonInstanceOf, isNonKey, isNonNullable, isNonNullableOrEmpty, isNonNullableOrWhitespace, isNonNumber, isNonNumerical, isNonObject, isNonPlainObject, isNonPrimitive, isNonTypedArray, isNullable, isNullableOrEmpty, isNullableOrWhitespace, isNumber, isNumerical, isObject, isObservable, isOk, isPlainObject, isPrimitive, isQueue, isQueueInstance, isRejected, isResult, isRgbColor, isRgbaColor, isSorted, isSubscription, isTimedLogger, isTypedArray, join, kebabCase, keyedQueue, last, lastIndexOf, lastOrDefault, lowerCase, matchResult, max, median, memoize, merge, min, move, moveIndices, moveToIndex, noop, normalize, ok, omit, once, parse, partition, pascalCase, pick, pipe, promises, push, queue, range, registerCloner, registerComparator, registerEqualizer, resultPromises, retry, reverse, rgbToHex, rgbToHsl, rgbToHsla, rgbToHwb, rgbToHwba, round, select, setValue, settlePromise, shake, shuffle, single, slice, smush, snakeCase, sort, splice, startsWith, startsWithArray, sum, swap, take, template, throttle, timed, times, titleCase, toMap, toMapArrays, toQuery, toRecord, toRecordArrays, toResult, toSet, toggle, transform, trim, truncate, tryDecode, tryEncode, union, unique, unsmush, unwrap, update, upperCase, words };