@oscarpalmer/atoms 0.189.1 → 0.190.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 (46) hide show
  1. package/dist/beacon.d.mts +51 -31
  2. package/dist/beacon.mjs +163 -141
  3. package/dist/color/index.d.mts +1 -2
  4. package/dist/color/index.mjs +2 -2
  5. package/dist/color/instance.d.mts +3 -167
  6. package/dist/color/instance.mjs +58 -217
  7. package/dist/color/misc/get.d.mts +1 -2
  8. package/dist/color/misc/get.mjs +3 -3
  9. package/dist/color/misc/index.d.mts +4 -4
  10. package/dist/color/misc/index.mjs +9 -9
  11. package/dist/color/misc/is.d.mts +1 -2
  12. package/dist/color/models.d.mts +158 -2
  13. package/dist/function/memoize.d.mts +3 -9
  14. package/dist/function/memoize.mjs +43 -90
  15. package/dist/function/once.mjs +16 -4
  16. package/dist/herald.d.mts +19 -15
  17. package/dist/herald.mjs +79 -89
  18. package/dist/index.d.mts +173 -162
  19. package/dist/index.mjs +750 -995
  20. package/dist/internal/result.d.mts +6 -6
  21. package/dist/internal/result.mjs +1 -1
  22. package/dist/internal/value/has.d.mts +2 -2
  23. package/dist/logger.d.mts +7 -7
  24. package/dist/logger.mjs +72 -51
  25. package/dist/promise/helpers.d.mts +2 -2
  26. package/dist/promise/helpers.mjs +2 -2
  27. package/dist/queue.d.mts +24 -12
  28. package/dist/queue.mjs +288 -346
  29. package/dist/string/fuzzy.d.mts +4 -13
  30. package/dist/string/fuzzy.mjs +15 -41
  31. package/package.json +2 -2
  32. package/src/beacon.ts +262 -160
  33. package/src/color/index.ts +8 -8
  34. package/src/color/instance.ts +82 -258
  35. package/src/color/misc/get.ts +4 -4
  36. package/src/color/misc/index.ts +10 -11
  37. package/src/color/models.ts +180 -2
  38. package/src/function/memoize.ts +74 -65
  39. package/src/function/once.ts +4 -0
  40. package/src/herald.ts +136 -94
  41. package/src/internal/result.ts +6 -6
  42. package/src/internal/value/has.ts +2 -2
  43. package/src/logger.ts +93 -42
  44. package/src/promise/helpers.ts +2 -2
  45. package/src/queue.ts +480 -375
  46. package/src/string/fuzzy.ts +36 -31
package/dist/beacon.d.mts CHANGED
@@ -2,12 +2,15 @@
2
2
  /**
3
3
  * A beacon is a lighthouse, holding an observable value that can be subscribed to and emitted from
4
4
  */
5
- declare class Beacon<Value> {
6
- #private;
5
+ type Beacon<Value> = {
7
6
  /**
8
7
  * Is the beacon active?
9
8
  */
10
9
  get active(): boolean;
10
+ /**
11
+ * Is the beacon closed?
12
+ */
13
+ get closed(): boolean;
11
14
  /**
12
15
  * The observable that can be subscribed to
13
16
  */
@@ -16,11 +19,10 @@ declare class Beacon<Value> {
16
19
  * The current value
17
20
  */
18
21
  get value(): Value;
19
- constructor(value: Value, options?: BeaconOptions<Value>);
20
22
  /**
21
- * Destroy the beacon
23
+ * Close the beacon
22
24
  */
23
- destroy(): void;
25
+ close(): void;
24
26
  /**
25
27
  * Emit a new value
26
28
  *
@@ -39,7 +41,7 @@ declare class Beacon<Value> {
39
41
  * Finish the beacon
40
42
  */
41
43
  finish(): void;
42
- }
44
+ };
43
45
  /**
44
46
  * Options for Beacon
45
47
  */
@@ -54,16 +56,19 @@ type BeaconOptions<Value> = {
54
56
  */
55
57
  equal?: (first: Value, second: Value) => boolean;
56
58
  };
57
- /**
58
- * An observable holds a value and allows observers to subscribe to changes in that value
59
- */
60
- declare class Observable<Value> {
61
- #private;
62
- constructor(instance: Beacon<Value>, observers: Map<Subscription<Value>, Observer<Value>>);
59
+ type Observable<Value> = {
60
+ /**
61
+ * Is the observable active?
62
+ */
63
+ get active(): boolean;
63
64
  /**
64
- * Destroy the observable
65
+ * Is the observable closed?
65
66
  */
66
- destroy(): void;
67
+ get closed(): boolean;
68
+ /**
69
+ * Close the observable
70
+ */
71
+ close(): void;
67
72
  /**
68
73
  * Subscribe to value changes
69
74
  *
@@ -72,19 +77,14 @@ declare class Observable<Value> {
72
77
  * @param onComplete Callback for when the observable is completed
73
78
  * @returns Subscription to the observable
74
79
  */
75
- subscribe(onNext: (value: Value) => void, onError?: (error: Error) => void, onComplete?: () => void): Subscription<Value>;
80
+ subscribe(onNext: (value: Value) => void, onError?: (error: Error) => void, onComplete?: () => void): Subscription;
76
81
  /**
77
82
  * Subscribe to value changes
78
83
  *
79
84
  * @param observer Observer for changes
80
85
  * @returns Subscription to the observable
81
86
  */
82
- subscribe(observer: Observer<Value>): Subscription<Value>;
83
- }
84
- type ObservableState<Value> = {
85
- beacon: Beacon<Value>;
86
- closed: boolean;
87
- observers: Map<Subscription<Value>, Observer<Value>>;
87
+ subscribe(observer: Observer<Value>): Subscription;
88
88
  };
89
89
  /**
90
90
  * An observer receives notifications from an observable
@@ -103,25 +103,24 @@ type Observer<Value> = {
103
103
  */
104
104
  next?: (value: Value) => void;
105
105
  };
106
- /**
107
- * A subscription represents an active subscription to an observable, holding its state and allowing it to be destroyed or unsubscribed from
108
- */
109
- declare class Subscription<Value> {
110
- #private;
111
- constructor(state: ObservableState<Value>);
106
+ type Subscription = {
107
+ /**
108
+ * Is the subscription active?
109
+ */
110
+ get active(): boolean;
112
111
  /**
113
112
  * Is the subscription closed?
114
113
  */
115
114
  get closed(): boolean;
116
115
  /**
117
- * Destroy the subscription
116
+ * Close the subscription
118
117
  */
119
- destroy(): void;
118
+ close(): void;
120
119
  /**
121
120
  * Unsubscribe from its observable
122
121
  */
123
122
  unsubscribe(): void;
124
- }
123
+ };
125
124
  /**
126
125
  * Create a new beacon
127
126
  *
@@ -130,5 +129,26 @@ declare class Subscription<Value> {
130
129
  * @returns Beacon instance
131
130
  */
132
131
  declare function beacon<Value>(value: Value, options?: BeaconOptions<Value>): Beacon<Value>;
132
+ /**
133
+ * Is the value a beacon?
134
+ *
135
+ * @param value Value to check
136
+ * @returns `true` if the value is a beacon, otherwise `false`
137
+ */
138
+ declare function isBeacon<Value = unknown>(value: unknown): value is Beacon<Value>;
139
+ /**
140
+ * Is the value an observable?
141
+ *
142
+ * @param value Value to check
143
+ * @returns `true` if the value is an observable, otherwise `false`
144
+ */
145
+ declare function isObservable<Value = unknown>(value: unknown): value is Observable<Value>;
146
+ /**
147
+ * Is the value a subscription?
148
+ *
149
+ * @param value Value to check
150
+ * @returns `true` if the value is a subscription, otherwise `false`
151
+ */
152
+ declare function isSubscription(value: unknown): value is Subscription;
133
153
  //#endregion
134
- export { type Beacon, type BeaconOptions, type Observable, type Observer, type Subscription, beacon };
154
+ export { Beacon, BeaconOptions, Observable, Subscription, beacon, isBeacon, isObservable, isSubscription };
package/dist/beacon.mjs CHANGED
@@ -2,141 +2,6 @@ import { noop } from "./internal/function/misc.mjs";
2
2
  import { isPlainObject } from "./internal/is.mjs";
3
3
  //#region src/beacon.ts
4
4
  /**
5
- * A beacon is a lighthouse, holding an observable value that can be subscribed to and emitted from
6
- */
7
- var Beacon = class {
8
- #options;
9
- #state;
10
- /**
11
- * Is the beacon active?
12
- */
13
- get active() {
14
- return this.#state.active;
15
- }
16
- /**
17
- * The observable that can be subscribed to
18
- */
19
- get observable() {
20
- if (!this.#state.active) throw new Error(MESSAGE_BEACON);
21
- return this.#state.observable;
22
- }
23
- /**
24
- * The current value
25
- */
26
- get value() {
27
- return this.#state.value;
28
- }
29
- constructor(value, options) {
30
- const observers = /* @__PURE__ */ new Map();
31
- this.#options = getBeaconOptions(options);
32
- this.#state = {
33
- observers,
34
- value,
35
- active: true,
36
- observable: new Observable(this, observers)
37
- };
38
- }
39
- /**
40
- * Destroy the beacon
41
- */
42
- destroy() {
43
- finishBeacon(this.#state, false);
44
- }
45
- /**
46
- * Emit a new value
47
- *
48
- * @param value Value to set and emit
49
- * @param finish Finish the beacon after emitting? _(defaults to `false`)_
50
- */
51
- emit(value, finish) {
52
- this.#on(TYPE_NEXT, value, finish);
53
- }
54
- /**
55
- * Emit an error
56
- *
57
- * @param value Error to emit
58
- * @param finish Finish the beacon after emitting? _(defaults to `false`)_
59
- */
60
- error(value, finish) {
61
- this.#on(TYPE_ERROR, value, finish);
62
- }
63
- /**
64
- * Finish the beacon
65
- */
66
- finish() {
67
- finishBeacon(this.#state, true);
68
- }
69
- #on(type, value, finish) {
70
- if (!this.#state.active) return;
71
- if (type === TYPE_NEXT) {
72
- if (this.#options.equal(this.#state.value, value)) return;
73
- this.#state.value = value;
74
- }
75
- for (const [, observer] of this.#state.observers) observer[type]?.(value);
76
- if (finish === true) finishBeacon(this.#state, true);
77
- }
78
- };
79
- /**
80
- * An observable holds a value and allows observers to subscribe to changes in that value
81
- */
82
- var Observable = class {
83
- #state;
84
- constructor(instance, observers) {
85
- this.#state = {
86
- observers,
87
- beacon: instance,
88
- closed: false
89
- };
90
- }
91
- /**
92
- * Destroy the observable
93
- */
94
- destroy() {
95
- this.#state.closed = true;
96
- }
97
- subscribe(first, second, third) {
98
- if (this.#state.closed) throw new Error(MESSAGE_OBSERVABLE);
99
- const observer = getObserver(first, second, third);
100
- const instance = new Subscription(this.#state);
101
- this.#state.observers.set(instance, observer);
102
- observer.next?.(this.#state.beacon.value);
103
- return instance;
104
- }
105
- };
106
- /**
107
- * A subscription represents an active subscription to an observable, holding its state and allowing it to be destroyed or unsubscribed from
108
- */
109
- var Subscription = class {
110
- #state;
111
- constructor(state) {
112
- this.#state = {
113
- ...state,
114
- closed: false
115
- };
116
- }
117
- /**
118
- * Is the subscription closed?
119
- */
120
- get closed() {
121
- return this.#state.closed || !this.#state.beacon.active;
122
- }
123
- /**
124
- * Destroy the subscription
125
- */
126
- destroy() {
127
- if (!this.#state.closed) this.unsubscribe();
128
- }
129
- /**
130
- * Unsubscribe from its observable
131
- */
132
- unsubscribe() {
133
- if (!this.#state.closed) {
134
- this.#state.closed = true;
135
- this.#state.observers.delete(this);
136
- }
137
- }
138
- };
139
- /**
140
5
  * Create a new beacon
141
6
  *
142
7
  * @param value Initial value
@@ -144,7 +9,54 @@ var Subscription = class {
144
9
  * @returns Beacon instance
145
10
  */
146
11
  function beacon(value, options) {
147
- return new Beacon(value, options);
12
+ const state = {
13
+ value,
14
+ active: true,
15
+ observable: void 0,
16
+ observers: /* @__PURE__ */ new Map(),
17
+ options: getBeaconOptions(options)
18
+ };
19
+ const instance = {
20
+ close: () => {
21
+ finishBeacon(state, false);
22
+ },
23
+ emit: (value, finish) => {
24
+ update(TYPE_NEXT, state, value, finish);
25
+ },
26
+ error: (value, finish) => {
27
+ update(TYPE_ERROR, state, value, finish);
28
+ },
29
+ finish: () => {
30
+ finishBeacon(state, true);
31
+ }
32
+ };
33
+ Object.defineProperties(instance, {
34
+ [KEY_BEACON]: {
35
+ enumerable: false,
36
+ value: NAME_BEACON
37
+ },
38
+ active: {
39
+ enumerable: true,
40
+ get: () => state.active
41
+ },
42
+ closed: {
43
+ enumerable: true,
44
+ get: () => !state.active
45
+ },
46
+ observable: {
47
+ enumerable: true,
48
+ get: () => {
49
+ if (!state.active) throw new Error(MESSAGE_BEACON);
50
+ state.observable ??= observe(state);
51
+ return state.observable;
52
+ }
53
+ },
54
+ value: {
55
+ enumerable: true,
56
+ get: () => state.value
57
+ }
58
+ });
59
+ return Object.freeze(instance);
148
60
  }
149
61
  function finishBeacon(state, emit) {
150
62
  if (!state.active) return;
@@ -154,10 +66,11 @@ function finishBeacon(state, emit) {
154
66
  for (let index = 0; index < length; index += 1) {
155
67
  const [subscription, observer] = entries[index];
156
68
  if (emit) observer.complete?.();
157
- subscription.destroy();
69
+ subscription.close();
158
70
  }
159
- state.observable?.destroy();
71
+ state.observable?.close();
160
72
  state.observers.clear();
73
+ state.observable = void 0;
161
74
  }
162
75
  function getBeaconOptions(input) {
163
76
  const options = isPlainObject(input) ? input : {};
@@ -181,9 +94,118 @@ function getObserver(first, second, third) {
181
94
  }
182
95
  return observer;
183
96
  }
184
- const MESSAGE_BEACON = "Cannot retrieve observable from a destroyed beacon";
185
- const MESSAGE_OBSERVABLE = "Cannot subscribe to a destroyed observable";
97
+ /**
98
+ * Is the value a beacon?
99
+ *
100
+ * @param value Value to check
101
+ * @returns `true` if the value is a beacon, otherwise `false`
102
+ */
103
+ function isBeacon(value) {
104
+ return isBeaconInstance(NAME_BEACON, value);
105
+ }
106
+ function isBeaconInstance(name, value) {
107
+ return isPlainObject(value) && value[KEY_BEACON] === name;
108
+ }
109
+ /**
110
+ * Is the value an observable?
111
+ *
112
+ * @param value Value to check
113
+ * @returns `true` if the value is an observable, otherwise `false`
114
+ */
115
+ function isObservable(value) {
116
+ return isBeaconInstance(NAME_OBSERVABLE, value);
117
+ }
118
+ /**
119
+ * Is the value a subscription?
120
+ *
121
+ * @param value Value to check
122
+ * @returns `true` if the value is a subscription, otherwise `false`
123
+ */
124
+ function isSubscription(value) {
125
+ return isBeaconInstance(NAME_SUBSCRIPTION, value);
126
+ }
127
+ function observe(beacon) {
128
+ const state = {
129
+ beacon,
130
+ active: beacon.active
131
+ };
132
+ const instance = {
133
+ close: () => {
134
+ state.active = false;
135
+ },
136
+ subscribe(first, second, third) {
137
+ if (!beacon.active || !state.active) throw new Error(MESSAGE_OBSERVABLE);
138
+ const observer = getObserver(first, second, third);
139
+ const subscription = subscribe(state);
140
+ beacon.observers.set(subscription, observer);
141
+ observer.next?.(beacon.value);
142
+ return subscription;
143
+ }
144
+ };
145
+ Object.defineProperties(instance, {
146
+ [KEY_BEACON]: {
147
+ enumerable: false,
148
+ value: NAME_OBSERVABLE
149
+ },
150
+ active: {
151
+ enumerable: true,
152
+ get: () => beacon.active && state.active
153
+ },
154
+ closed: {
155
+ enumerable: true,
156
+ get: () => !beacon.active || !state.active
157
+ }
158
+ });
159
+ return Object.freeze(instance);
160
+ }
161
+ function subscribe(observable) {
162
+ function unsubscribe() {
163
+ if (active) {
164
+ active = false;
165
+ observable.beacon.observers.delete(instance);
166
+ }
167
+ }
168
+ let active = true;
169
+ const instance = {
170
+ close: () => {
171
+ unsubscribe();
172
+ },
173
+ unsubscribe: () => {
174
+ unsubscribe();
175
+ }
176
+ };
177
+ Object.defineProperties(instance, {
178
+ [KEY_BEACON]: {
179
+ enumerable: false,
180
+ value: NAME_SUBSCRIPTION
181
+ },
182
+ active: {
183
+ enumerable: true,
184
+ get: () => observable.beacon.active && observable.active && active
185
+ },
186
+ closed: {
187
+ enumerable: true,
188
+ get: () => !observable.beacon.active || !observable.active || !active
189
+ }
190
+ });
191
+ return Object.freeze(instance);
192
+ }
193
+ function update(type, state, value, finish) {
194
+ if (!state.active) return;
195
+ if (type === TYPE_NEXT) {
196
+ if (state.options.equal(state.value, value)) return;
197
+ state.value = value;
198
+ }
199
+ for (const [, observer] of state.observers) observer[type]?.(value);
200
+ if (finish === true) finishBeacon(state, true);
201
+ }
202
+ const KEY_BEACON = "$beacon";
203
+ const MESSAGE_BEACON = "Cannot retrieve observable from a closed beacon";
204
+ const MESSAGE_OBSERVABLE = "Cannot subscribe to a closed observable";
205
+ const NAME_BEACON = "beacon";
206
+ const NAME_OBSERVABLE = "observable";
207
+ const NAME_SUBSCRIPTION = "subscription";
186
208
  const TYPE_ERROR = "error";
187
209
  const TYPE_NEXT = "next";
188
210
  //#endregion
189
- export { beacon };
211
+ export { beacon, isBeacon, isObservable, isSubscription };
@@ -1,5 +1,4 @@
1
- import { HSLAColor, HSLColor, HWBAColor, HWBColor, RGBAColor, RGBColor } from "./models.mjs";
2
- import { Color } from "./instance.mjs";
1
+ import { Color, HSLAColor, HSLColor, HWBAColor, HWBColor, RGBAColor, RGBColor } from "./models.mjs";
3
2
  import { getForegroundColor, getHexColor, getHexaColor, getHslColor, getHslaColor, getHwbColor, getHwbaColor, getRgbColor, getRgbaColor } from "./misc/get.mjs";
4
3
  import { isColor, isHexColor, isHslColor, isHslLike, isHslaColor, isHwbColor, isHwbLike, isHwbaColor, isHwbaLike, isRgbColor, isRgbLike, isRgbaColor } from "./misc/is.mjs";
5
4
  import { getNormalizedHex, hexToHsl, hexToHsla, hexToHwb, hexToHwba, hexToRgb, hexToRgba } from "./space/hex.mjs";
@@ -4,7 +4,7 @@ import { rgbToHex, rgbToHsl, rgbToHsla, rgbToHwb, rgbToHwba } from "./space/rgb.
4
4
  import { getNormalizedHex, hexToHsl, hexToHsla, hexToHwb, hexToHwba, hexToRgb, hexToRgba } from "./space/hex.mjs";
5
5
  import { hslToHex, hslToHwb, hslToHwba, hslToRgb, hslToRgba } from "./space/hsl.mjs";
6
6
  import { hwbToHex, hwbToHsl, hwbToHsla, hwbToRgb, hwbToRgba } from "./space/hwb.mjs";
7
- import { Color } from "./instance.mjs";
7
+ import { color } from "./instance.mjs";
8
8
  //#region src/color/index.ts
9
9
  /**
10
10
  * Get a _Color_ from any kind of value
@@ -16,7 +16,7 @@ import { Color } from "./instance.mjs";
16
16
  * @returns _Color_ instance
17
17
  */
18
18
  function getColor(value) {
19
- return isColor(value) ? value : new Color(value);
19
+ return isColor(value) ? value : color(value);
20
20
  }
21
21
  //#endregion
22
22
  export { getColor, getForegroundColor, getHexColor, getHexaColor, getHslColor, getHslaColor, getHwbColor, getHwbaColor, getNormalizedHex, getRgbColor, getRgbaColor, hexToHsl, hexToHsla, hexToHwb, hexToHwba, hexToRgb, hexToRgba, hslToHex, hslToHwb, hslToHwba, hslToRgb, hslToRgba, hwbToHex, hwbToHsl, hwbToHsla, hwbToRgb, hwbToRgba, isColor, isHexColor, isHslColor, isHslLike, isHslaColor, isHwbColor, isHwbLike, isHwbaColor, isHwbaLike, isRgbColor, isRgbLike, isRgbaColor, rgbToHex, rgbToHsl, rgbToHsla, rgbToHwb, rgbToHwba };
@@ -1,169 +1,5 @@
1
- import { HSLAColor, HSLColor, HWBAColor, HWBColor, RGBAColor, RGBColor } from "./models.mjs";
1
+ import { Color } from "./models.mjs";
2
2
  //#region src/color/instance.d.ts
3
- /**
4
- * A color that is represented in multiple color formats
5
- */
6
- declare class Color {
7
- #private;
8
- /**
9
- * A property to identify this as a Color instance, used for type checking
10
- *
11
- * @internal
12
- */
13
- private readonly $color;
14
- /**
15
- * Get the alpha channel _(opacity)_ of the color as a percentage between `0` and `100`
16
- *
17
- * @returns Current alpha channel value
18
- */
19
- get alpha(): number;
20
- /**
21
- * Set the alpha channel _(opacity)_ of the color as a percentage between `0` and `100`
22
- *
23
- * @param value New alpha channel value
24
- */
25
- set alpha(value: number);
26
- /**
27
- * Get the color as a hex color string
28
- *
29
- * _Hex color string is returned with no `#`-prefix or alpha channel (opacity)_
30
- *
31
- * @returns Current color as a hex color string
32
- */
33
- get hex(): string;
34
- /**
35
- * Set the color from a hex color string
36
- *
37
- * - `#`-prefix is optional
38
- * - Alpha channel _(opacity)_ will be ignored
39
- *
40
- * @param value New hex color string
41
- */
42
- set hex(value: string);
43
- /**
44
- * Get the color as a hex color with an alpha channel _(opacity)_
45
- *
46
- * _Hex color string is returned with alpha channel (opacity), but without `#`-prefix_
47
- *
48
- * @returns Current color as a hex color string
49
- */
50
- get hexa(): string;
51
- /**
52
- * Set the color from a hex color string with an alpha channel _(opacity)_
53
- *
54
- * - `#`-prefix is optional
55
- * - Alpha channel _(opacity)_ will be respected
56
- *
57
- * @param value New hex color string
58
- */
59
- set hexa(value: string);
60
- /**
61
- * Get the color as an _HSL_ color
62
- *
63
- * @returns Current color as an _HSL_ color
64
- */
65
- get hsl(): HSLColor;
66
- /**
67
- * Set colors from an _HSL_ color
68
- *
69
- * @param value New _HSL_ color
70
- */
71
- set hsl(value: HSLColor);
72
- /**
73
- * Get the color as an _HSLA_ color
74
- *
75
- * @returns Current color as an _HSLA_ color
76
- */
77
- get hsla(): HSLAColor;
78
- /**
79
- * Set colors and alpha from an _HSLA_ color
80
- *
81
- * @param value New _HSLA_ color
82
- */
83
- set hsla(value: HSLAColor);
84
- /**
85
- * Get the color as an _HWB_ color
86
- *
87
- * @returns Current color as an _HWB_ color
88
- */
89
- get hwb(): HWBColor;
90
- /**
91
- * Set colors from an _HWB_ color
92
- *
93
- * @param value New _HWB_ color
94
- */
95
- set hwb(value: HWBColor);
96
- /**
97
- * Get the color as an _HWBA_ color
98
- *
99
- * @returns Current color as an _HWBA_ color
100
- */
101
- get hwba(): HWBAColor;
102
- /**
103
- * Set colors and alpha from an _HWBA_ color
104
- *
105
- * @param value New _HWBA_ color
106
- */
107
- set hwba(value: HWBAColor);
108
- /**
109
- * Get the color as an _RGB_ color
110
- *
111
- * @returns Current color as an _RGB_ color
112
- */
113
- get rgb(): RGBColor;
114
- /**
115
- * Set colors from an _RGB_ color
116
- *
117
- * @param value New _RGB_ color
118
- */
119
- set rgb(value: RGBColor);
120
- /**
121
- * Get the color as an _RGBA_ color
122
- *
123
- * @returns Current color as an _RGBA_ color
124
- */
125
- get rgba(): RGBAColor;
126
- /**
127
- * Set colors and alpha from an _RGBA_ color
128
- *
129
- * @param value New _RGBA_ color
130
- */
131
- set rgba(value: RGBAColor);
132
- constructor(value: unknown);
133
- /**
134
- * Get the color as a hex string
135
- *
136
- * @param alpha Include alpha channel _(opacity)_? _(defaults to `false`)_
137
- * @returns Hex color string
138
- */
139
- toHexString(alpha?: boolean): string;
140
- /**
141
- * Get the color as an _HSL(A)_ string
142
- *
143
- * @param alpha Include alpha channel _(opacity)_? _(defaults to `false`)_
144
- * @returns _HSL(A)_ color string
145
- */
146
- toHslString(alpha?: boolean): string;
147
- /**
148
- * Get the color as an _HWB(A)_ string
149
- *
150
- * @param alpha Include alpha channel _(opacity)_? _(defaults to `false`)_
151
- * @returns _HWB(A)_ color string
152
- */
153
- toHwbString(alpha?: boolean): string;
154
- /**
155
- * Get the color as an _RGB(A)_ string
156
- *
157
- * @param alpha Include alpha channel _(opacity)_? _(defaults to `false`)_
158
- * @returns _RGB(A)_ color string
159
- */
160
- toRgbString(alpha?: boolean): string;
161
- /**
162
- * Get the color as a hex color string
163
- *
164
- * @returns Hex color string
165
- */
166
- toString(): string;
167
- }
3
+ declare function color(value: unknown): Color;
168
4
  //#endregion
169
- export { Color };
5
+ export { color };