@oscarpalmer/atoms 0.189.0 → 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.
- package/dist/beacon.d.mts +51 -31
- package/dist/beacon.mjs +163 -141
- package/dist/color/index.d.mts +1 -2
- package/dist/color/index.mjs +2 -2
- package/dist/color/instance.d.mts +3 -167
- package/dist/color/instance.mjs +58 -217
- package/dist/color/misc/get.d.mts +1 -2
- package/dist/color/misc/get.mjs +3 -3
- package/dist/color/misc/index.d.mts +4 -4
- package/dist/color/misc/index.mjs +9 -9
- package/dist/color/misc/is.d.mts +1 -2
- package/dist/color/misc/is.mjs +5 -2
- package/dist/color/models.d.mts +158 -2
- package/dist/function/memoize.d.mts +3 -9
- package/dist/function/memoize.mjs +43 -90
- package/dist/function/once.mjs +16 -4
- package/dist/herald.d.mts +19 -15
- package/dist/herald.mjs +79 -89
- package/dist/index.d.mts +173 -162
- package/dist/index.mjs +754 -996
- package/dist/internal/result.d.mts +6 -6
- package/dist/internal/result.mjs +1 -1
- package/dist/internal/value/has.d.mts +2 -2
- package/dist/logger.d.mts +7 -7
- package/dist/logger.mjs +72 -51
- package/dist/promise/helpers.d.mts +2 -2
- package/dist/promise/helpers.mjs +2 -2
- package/dist/queue.d.mts +24 -12
- package/dist/queue.mjs +288 -346
- package/dist/string/fuzzy.d.mts +4 -13
- package/dist/string/fuzzy.mjs +15 -41
- package/package.json +2 -2
- package/src/beacon.ts +262 -160
- package/src/color/index.ts +8 -8
- package/src/color/instance.ts +82 -258
- package/src/color/misc/get.ts +4 -4
- package/src/color/misc/index.ts +10 -11
- package/src/color/misc/is.ts +4 -1
- package/src/color/models.ts +180 -2
- package/src/function/memoize.ts +74 -65
- package/src/function/once.ts +4 -0
- package/src/herald.ts +136 -94
- package/src/internal/result.ts +6 -6
- package/src/internal/value/has.ts +2 -2
- package/src/logger.ts +93 -42
- package/src/promise/helpers.ts +2 -2
- package/src/queue.ts +480 -375
- package/src/string/fuzzy.ts +36 -31
package/dist/color/instance.mjs
CHANGED
|
@@ -2,222 +2,63 @@ import { formatHslColor, formatHwbColor, formatRgbColor } from "./misc/index.mjs
|
|
|
2
2
|
import { getAlpha } from "./misc/alpha.mjs";
|
|
3
3
|
import { getColorState, setHSLColor, setHWBColor, setHexColor, setRGBColor } from "./misc/state.mjs";
|
|
4
4
|
//#region src/color/instance.ts
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
*
|
|
63
|
-
* @param value New hex color string
|
|
64
|
-
*/
|
|
65
|
-
set hexa(value) {
|
|
66
|
-
setHexColor(this.#state, value, true);
|
|
67
|
-
}
|
|
68
|
-
/**
|
|
69
|
-
* Get the color as an _HSL_ color
|
|
70
|
-
*
|
|
71
|
-
* @returns Current color as an _HSL_ color
|
|
72
|
-
*/
|
|
73
|
-
get hsl() {
|
|
74
|
-
return { ...this.#state.hsl };
|
|
75
|
-
}
|
|
76
|
-
/**
|
|
77
|
-
* Set colors from an _HSL_ color
|
|
78
|
-
*
|
|
79
|
-
* @param value New _HSL_ color
|
|
80
|
-
*/
|
|
81
|
-
set hsl(value) {
|
|
82
|
-
setHSLColor(this.#state, value, false);
|
|
83
|
-
}
|
|
84
|
-
/**
|
|
85
|
-
* Get the color as an _HSLA_ color
|
|
86
|
-
*
|
|
87
|
-
* @returns Current color as an _HSLA_ color
|
|
88
|
-
*/
|
|
89
|
-
get hsla() {
|
|
90
|
-
return {
|
|
91
|
-
...this.#state.hsl,
|
|
92
|
-
alpha: this.#state.alpha.value
|
|
93
|
-
};
|
|
94
|
-
}
|
|
95
|
-
/**
|
|
96
|
-
* Set colors and alpha from an _HSLA_ color
|
|
97
|
-
*
|
|
98
|
-
* @param value New _HSLA_ color
|
|
99
|
-
*/
|
|
100
|
-
set hsla(value) {
|
|
101
|
-
setHSLColor(this.#state, value, true);
|
|
102
|
-
}
|
|
103
|
-
/**
|
|
104
|
-
* Get the color as an _HWB_ color
|
|
105
|
-
*
|
|
106
|
-
* @returns Current color as an _HWB_ color
|
|
107
|
-
*/
|
|
108
|
-
get hwb() {
|
|
109
|
-
return { ...this.#state.hwb };
|
|
110
|
-
}
|
|
111
|
-
/**
|
|
112
|
-
* Set colors from an _HWB_ color
|
|
113
|
-
*
|
|
114
|
-
* @param value New _HWB_ color
|
|
115
|
-
*/
|
|
116
|
-
set hwb(value) {
|
|
117
|
-
setHWBColor(this.#state, value, false);
|
|
118
|
-
}
|
|
119
|
-
/**
|
|
120
|
-
* Get the color as an _HWBA_ color
|
|
121
|
-
*
|
|
122
|
-
* @returns Current color as an _HWBA_ color
|
|
123
|
-
*/
|
|
124
|
-
get hwba() {
|
|
125
|
-
return {
|
|
126
|
-
...this.#state.hwb,
|
|
127
|
-
alpha: this.#state.alpha.value
|
|
128
|
-
};
|
|
129
|
-
}
|
|
130
|
-
/**
|
|
131
|
-
* Set colors and alpha from an _HWBA_ color
|
|
132
|
-
*
|
|
133
|
-
* @param value New _HWBA_ color
|
|
134
|
-
*/
|
|
135
|
-
set hwba(value) {
|
|
136
|
-
setHWBColor(this.#state, value, true);
|
|
137
|
-
}
|
|
138
|
-
/**
|
|
139
|
-
* Get the color as an _RGB_ color
|
|
140
|
-
*
|
|
141
|
-
* @returns Current color as an _RGB_ color
|
|
142
|
-
*/
|
|
143
|
-
get rgb() {
|
|
144
|
-
return { ...this.#state.rgb };
|
|
145
|
-
}
|
|
146
|
-
/**
|
|
147
|
-
* Set colors from an _RGB_ color
|
|
148
|
-
*
|
|
149
|
-
* @param value New _RGB_ color
|
|
150
|
-
*/
|
|
151
|
-
set rgb(value) {
|
|
152
|
-
setRGBColor(this.#state, value, false);
|
|
153
|
-
}
|
|
154
|
-
/**
|
|
155
|
-
* Get the color as an _RGBA_ color
|
|
156
|
-
*
|
|
157
|
-
* @returns Current color as an _RGBA_ color
|
|
158
|
-
*/
|
|
159
|
-
get rgba() {
|
|
160
|
-
return {
|
|
161
|
-
...this.#state.rgb,
|
|
162
|
-
alpha: this.#state.alpha.value
|
|
163
|
-
};
|
|
164
|
-
}
|
|
165
|
-
/**
|
|
166
|
-
* Set colors and alpha from an _RGBA_ color
|
|
167
|
-
*
|
|
168
|
-
* @param value New _RGBA_ color
|
|
169
|
-
*/
|
|
170
|
-
set rgba(value) {
|
|
171
|
-
setRGBColor(this.#state, value, true);
|
|
172
|
-
}
|
|
173
|
-
constructor(value) {
|
|
174
|
-
this.#state = getColorState(value);
|
|
175
|
-
Object.defineProperty(this, "$color", { value: true });
|
|
176
|
-
}
|
|
177
|
-
/**
|
|
178
|
-
* Get the color as a hex string
|
|
179
|
-
*
|
|
180
|
-
* @param alpha Include alpha channel _(opacity)_? _(defaults to `false`)_
|
|
181
|
-
* @returns Hex color string
|
|
182
|
-
*/
|
|
183
|
-
toHexString(alpha) {
|
|
184
|
-
return `#${alpha === true ? this.hexa : this.hex}`;
|
|
185
|
-
}
|
|
186
|
-
/**
|
|
187
|
-
* Get the color as an _HSL(A)_ string
|
|
188
|
-
*
|
|
189
|
-
* @param alpha Include alpha channel _(opacity)_? _(defaults to `false`)_
|
|
190
|
-
* @returns _HSL(A)_ color string
|
|
191
|
-
*/
|
|
192
|
-
toHslString(alpha) {
|
|
193
|
-
return formatHslColor(this, alpha === true);
|
|
194
|
-
}
|
|
195
|
-
/**
|
|
196
|
-
* Get the color as an _HWB(A)_ string
|
|
197
|
-
*
|
|
198
|
-
* @param alpha Include alpha channel _(opacity)_? _(defaults to `false`)_
|
|
199
|
-
* @returns _HWB(A)_ color string
|
|
200
|
-
*/
|
|
201
|
-
toHwbString(alpha) {
|
|
202
|
-
return formatHwbColor(this, alpha === true);
|
|
203
|
-
}
|
|
204
|
-
/**
|
|
205
|
-
* Get the color as an _RGB(A)_ string
|
|
206
|
-
*
|
|
207
|
-
* @param alpha Include alpha channel _(opacity)_? _(defaults to `false`)_
|
|
208
|
-
* @returns _RGB(A)_ color string
|
|
209
|
-
*/
|
|
210
|
-
toRgbString(alpha) {
|
|
211
|
-
return formatRgbColor(this, alpha === true);
|
|
212
|
-
}
|
|
213
|
-
/**
|
|
214
|
-
* Get the color as a hex color string
|
|
215
|
-
*
|
|
216
|
-
* @returns Hex color string
|
|
217
|
-
*/
|
|
218
|
-
toString() {
|
|
219
|
-
return this.toHexString();
|
|
220
|
-
}
|
|
5
|
+
function color(value) {
|
|
6
|
+
const state = getColorState(value);
|
|
7
|
+
const instance = {
|
|
8
|
+
toHexString: (alpha) => `#${alpha === true ? instance.hexa : instance.hex}`,
|
|
9
|
+
toHslString: (alpha) => formatHslColor(state, alpha === true),
|
|
10
|
+
toHwbString: (alpha) => formatHwbColor(state, alpha === true),
|
|
11
|
+
toRgbString: (alpha) => formatRgbColor(state, alpha === true),
|
|
12
|
+
toString: () => instance.toHexString()
|
|
13
|
+
};
|
|
14
|
+
Object.defineProperties(instance, {
|
|
15
|
+
$color: {
|
|
16
|
+
enumerable: false,
|
|
17
|
+
get: () => true
|
|
18
|
+
},
|
|
19
|
+
alpha: {
|
|
20
|
+
enumerable: true,
|
|
21
|
+
get: () => state.alpha.value,
|
|
22
|
+
set: (value) => {
|
|
23
|
+
if (typeof value === "number" && !Number.isNaN(value)) state.alpha = getAlpha(value);
|
|
24
|
+
}
|
|
25
|
+
},
|
|
26
|
+
hex: getProperty("hex", state, false),
|
|
27
|
+
hexa: getProperty("hex", state, true),
|
|
28
|
+
hsl: getProperty("hsl", state, false),
|
|
29
|
+
hsla: getProperty("hsl", state, true),
|
|
30
|
+
hwb: getProperty("hwb", state, false),
|
|
31
|
+
hwba: getProperty("hwb", state, true),
|
|
32
|
+
rgb: getProperty("rgb", state, false),
|
|
33
|
+
rgba: getProperty("rgb", state, true)
|
|
34
|
+
});
|
|
35
|
+
return Object.freeze(instance);
|
|
36
|
+
}
|
|
37
|
+
function getHex(state, alpha) {
|
|
38
|
+
return alpha ? `${state.hex}${state.alpha.hex}` : state.hex;
|
|
39
|
+
}
|
|
40
|
+
function getProperty(space, state, alpha) {
|
|
41
|
+
const setter = setters[space];
|
|
42
|
+
return {
|
|
43
|
+
enumerable: true,
|
|
44
|
+
get: () => {
|
|
45
|
+
const value = state[space];
|
|
46
|
+
if (typeof value === "string") return getHex(state, alpha);
|
|
47
|
+
return alpha ? {
|
|
48
|
+
...value,
|
|
49
|
+
alpha: state.alpha.value
|
|
50
|
+
} : { ...value };
|
|
51
|
+
},
|
|
52
|
+
set: (value) => {
|
|
53
|
+
setter(state, value, alpha);
|
|
54
|
+
}
|
|
55
|
+
};
|
|
56
|
+
}
|
|
57
|
+
const setters = {
|
|
58
|
+
hex: setHexColor,
|
|
59
|
+
hsl: setHSLColor,
|
|
60
|
+
hwb: setHWBColor,
|
|
61
|
+
rgb: setRGBColor
|
|
221
62
|
};
|
|
222
63
|
//#endregion
|
|
223
|
-
export {
|
|
64
|
+
export { color };
|
|
@@ -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
|
//#region src/color/misc/get.d.ts
|
|
4
3
|
/**
|
|
5
4
|
* Get a foreground color _(usually text)_ based on a background color's luminance as an unprefixed hex color string
|
package/dist/color/misc/get.mjs
CHANGED
|
@@ -2,7 +2,7 @@ import { clamp } from "../../internal/number.mjs";
|
|
|
2
2
|
import { round } from "../../internal/math/misc.mjs";
|
|
3
3
|
import { HEX_BLACK, HEX_WHITE, SRGB_LUMINANCE_EXPONENT, SRGB_LUMINANCE_MODIFIER, SRGB_LUMINANCE_MULTIPLIER, SRGB_LUMINANCE_OFFSET } from "../constants.mjs";
|
|
4
4
|
import { getColorState } from "./state.mjs";
|
|
5
|
-
import {
|
|
5
|
+
import { color } from "../instance.mjs";
|
|
6
6
|
//#region src/color/misc/get.ts
|
|
7
7
|
function getClampedValue(value, minimum, maximum, rounding) {
|
|
8
8
|
return typeof value === "number" && !Number.isNaN(value) ? clamp(rounding ?? false ? round(value) : value, minimum, maximum) : minimum;
|
|
@@ -20,8 +20,8 @@ function getForegroundColor(value, hex) {
|
|
|
20
20
|
if (color <= .03928) values[index] /= SRGB_LUMINANCE_MULTIPLIER;
|
|
21
21
|
else values[index] = ((color + SRGB_LUMINANCE_OFFSET) / SRGB_LUMINANCE_MODIFIER) ** SRGB_LUMINANCE_EXPONENT;
|
|
22
22
|
}
|
|
23
|
-
const
|
|
24
|
-
return hex === true ?
|
|
23
|
+
const foreground = .2126 * values[2] + .7152 * values[1] + .0722 * values[0] > .625 ? HEX_BLACK : HEX_WHITE;
|
|
24
|
+
return hex === true ? foreground : color(foreground);
|
|
25
25
|
}
|
|
26
26
|
/**
|
|
27
27
|
* Get the hex color _(with alpha channel, i.e., opacity)_ from any kind of value
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { ColorState } from "../models.mjs";
|
|
2
2
|
//#region src/color/misc/index.d.ts
|
|
3
|
-
declare function formatHslColor(
|
|
4
|
-
declare function formatHwbColor(
|
|
5
|
-
declare function formatRgbColor(
|
|
3
|
+
declare function formatHslColor(state: ColorState, alpha: boolean): string;
|
|
4
|
+
declare function formatHwbColor(state: ColorState, alpha: boolean): string;
|
|
5
|
+
declare function formatRgbColor(state: ColorState, alpha: boolean): string;
|
|
6
6
|
//#endregion
|
|
7
7
|
export { formatHslColor, formatHwbColor, formatRgbColor };
|
|
@@ -1,15 +1,15 @@
|
|
|
1
1
|
//#region src/color/misc/index.ts
|
|
2
|
-
function formatHslColor(
|
|
3
|
-
const { hue, lightness, saturation } =
|
|
4
|
-
return `hsl(${hue}deg ${saturation}% ${lightness}%${alpha ? ` / ${
|
|
2
|
+
function formatHslColor(state, alpha) {
|
|
3
|
+
const { hue, lightness, saturation } = state.hsl;
|
|
4
|
+
return `hsl(${hue}deg ${saturation}% ${lightness}%${alpha ? ` / ${state.alpha.value}%` : ""})`;
|
|
5
5
|
}
|
|
6
|
-
function formatHwbColor(
|
|
7
|
-
const { blackness, hue, whiteness } =
|
|
8
|
-
return `hwb(${hue}deg ${whiteness}% ${blackness}%${alpha ? ` / ${
|
|
6
|
+
function formatHwbColor(state, alpha) {
|
|
7
|
+
const { blackness, hue, whiteness } = state.hwb;
|
|
8
|
+
return `hwb(${hue}deg ${whiteness}% ${blackness}%${alpha ? ` / ${state.alpha.value}%` : ""})`;
|
|
9
9
|
}
|
|
10
|
-
function formatRgbColor(
|
|
11
|
-
const { blue, green, red } =
|
|
12
|
-
return `rgb(${red} ${green} ${blue}${alpha ? ` / ${
|
|
10
|
+
function formatRgbColor(state, alpha) {
|
|
11
|
+
const { blue, green, red } = state.rgb;
|
|
12
|
+
return `rgb(${red} ${green} ${blue}${alpha ? ` / ${state.alpha.value}%` : ""})`;
|
|
13
13
|
}
|
|
14
14
|
//#endregion
|
|
15
15
|
export { formatHslColor, formatHwbColor, formatRgbColor };
|
package/dist/color/misc/is.d.mts
CHANGED
|
@@ -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
|
//#region src/color/misc/is.d.ts
|
|
4
3
|
/**
|
|
5
4
|
* Is the value a _Color_?
|
package/dist/color/misc/is.mjs
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { between } from "../../internal/number.mjs";
|
|
2
|
-
import { EXPRESSION_HEX_LONG, EXPRESSION_HEX_SHORT, KEYS_HSL, KEYS_HSLA, KEYS_HWB, KEYS_HWBA, KEYS_RGB, KEYS_RGBA } from "../constants.mjs";
|
|
2
|
+
import { EXPRESSION_HEX_LONG, EXPRESSION_HEX_SHORT, EXPRESSION_PREFIX, KEYS_HSL, KEYS_HSLA, KEYS_HWB, KEYS_HWBA, KEYS_RGB, KEYS_RGBA } from "../constants.mjs";
|
|
3
3
|
//#region src/color/misc/is.ts
|
|
4
4
|
function hasKeys(value, keys) {
|
|
5
5
|
return typeof value === "object" && value !== null && keys.every((key) => key in value);
|
|
@@ -52,7 +52,10 @@ function isDegree(value) {
|
|
|
52
52
|
function isHexColor(value, alpha) {
|
|
53
53
|
if (typeof value !== "string") return false;
|
|
54
54
|
if (!(EXPRESSION_HEX_SHORT.test(value) || EXPRESSION_HEX_LONG.test(value))) return false;
|
|
55
|
-
if (alpha === false)
|
|
55
|
+
if (alpha === false) {
|
|
56
|
+
const unprefixed = value.replace(EXPRESSION_PREFIX, "");
|
|
57
|
+
return unprefixed.length === 3 || unprefixed.length === 6;
|
|
58
|
+
}
|
|
56
59
|
return true;
|
|
57
60
|
}
|
|
58
61
|
/**
|
package/dist/color/models.d.mts
CHANGED
|
@@ -3,6 +3,163 @@ type Alpha = {
|
|
|
3
3
|
hex: string;
|
|
4
4
|
value: number;
|
|
5
5
|
};
|
|
6
|
+
/**
|
|
7
|
+
* A color that is represented in multiple color formats
|
|
8
|
+
*/
|
|
9
|
+
type Color = {
|
|
10
|
+
/**
|
|
11
|
+
* Get the alpha channel _(opacity)_ of the color as a percentage between `0` and `100`
|
|
12
|
+
*
|
|
13
|
+
* @returns Current alpha channel value
|
|
14
|
+
*/
|
|
15
|
+
get alpha(): number;
|
|
16
|
+
/**
|
|
17
|
+
* Set the alpha channel _(opacity)_ of the color as a percentage between `0` and `100`
|
|
18
|
+
*
|
|
19
|
+
* @param value New alpha channel value
|
|
20
|
+
*/
|
|
21
|
+
set alpha(value: number);
|
|
22
|
+
/**
|
|
23
|
+
* Get the color as a hex color string
|
|
24
|
+
*
|
|
25
|
+
* _Hex color string is returned with no `#`-prefix or alpha channel (opacity)_
|
|
26
|
+
*
|
|
27
|
+
* @returns Current color as a hex color string
|
|
28
|
+
*/
|
|
29
|
+
get hex(): string;
|
|
30
|
+
/**
|
|
31
|
+
* Set the color from a hex color string
|
|
32
|
+
*
|
|
33
|
+
* - `#`-prefix is optional
|
|
34
|
+
* - Alpha channel _(opacity)_ will be ignored
|
|
35
|
+
*
|
|
36
|
+
* @param value New hex color string
|
|
37
|
+
*/
|
|
38
|
+
set hex(value: string);
|
|
39
|
+
/**
|
|
40
|
+
* Get the color as a hex color with an alpha channel _(opacity)_
|
|
41
|
+
*
|
|
42
|
+
* _Hex color string is returned with alpha channel (opacity), but without `#`-prefix_
|
|
43
|
+
*
|
|
44
|
+
* @returns Current color as a hex color string
|
|
45
|
+
*/
|
|
46
|
+
get hexa(): string;
|
|
47
|
+
/**
|
|
48
|
+
* Set the color from a hex color string with an alpha channel _(opacity)_
|
|
49
|
+
*
|
|
50
|
+
* - `#`-prefix is optional
|
|
51
|
+
* - Alpha channel _(opacity)_ will be respected
|
|
52
|
+
*
|
|
53
|
+
* @param value New hex color string
|
|
54
|
+
*/
|
|
55
|
+
set hexa(value: string);
|
|
56
|
+
/**
|
|
57
|
+
* Get the color as an _HSL_ color
|
|
58
|
+
*
|
|
59
|
+
* @returns Current color as an _HSL_ color
|
|
60
|
+
*/
|
|
61
|
+
get hsl(): HSLColor;
|
|
62
|
+
/**
|
|
63
|
+
* Set colors from an _HSL_ color
|
|
64
|
+
*
|
|
65
|
+
* @param value New _HSL_ color
|
|
66
|
+
*/
|
|
67
|
+
set hsl(value: HSLColor);
|
|
68
|
+
/**
|
|
69
|
+
* Get the color as an _HSLA_ color
|
|
70
|
+
*
|
|
71
|
+
* @returns Current color as an _HSLA_ color
|
|
72
|
+
*/
|
|
73
|
+
get hsla(): HSLAColor;
|
|
74
|
+
/**
|
|
75
|
+
* Set colors and alpha from an _HSLA_ color
|
|
76
|
+
*
|
|
77
|
+
* @param value New _HSLA_ color
|
|
78
|
+
*/
|
|
79
|
+
set hsla(value: HSLAColor);
|
|
80
|
+
/**
|
|
81
|
+
* Get the color as an _HWB_ color
|
|
82
|
+
*
|
|
83
|
+
* @returns Current color as an _HWB_ color
|
|
84
|
+
*/
|
|
85
|
+
get hwb(): HWBColor;
|
|
86
|
+
/**
|
|
87
|
+
* Set colors from an _HWB_ color
|
|
88
|
+
*
|
|
89
|
+
* @param value New _HWB_ color
|
|
90
|
+
*/
|
|
91
|
+
set hwb(value: HWBColor);
|
|
92
|
+
/**
|
|
93
|
+
* Get the color as an _HWBA_ color
|
|
94
|
+
*
|
|
95
|
+
* @returns Current color as an _HWBA_ color
|
|
96
|
+
*/
|
|
97
|
+
get hwba(): HWBAColor;
|
|
98
|
+
/**
|
|
99
|
+
* Set colors and alpha from an _HWBA_ color
|
|
100
|
+
*
|
|
101
|
+
* @param value New _HWBA_ color
|
|
102
|
+
*/
|
|
103
|
+
set hwba(value: HWBAColor);
|
|
104
|
+
/**
|
|
105
|
+
* Get the color as an _RGB_ color
|
|
106
|
+
*
|
|
107
|
+
* @returns Current color as an _RGB_ color
|
|
108
|
+
*/
|
|
109
|
+
get rgb(): RGBColor;
|
|
110
|
+
/**
|
|
111
|
+
* Set colors from an _RGB_ color
|
|
112
|
+
*
|
|
113
|
+
* @param value New _RGB_ color
|
|
114
|
+
*/
|
|
115
|
+
set rgb(value: RGBColor);
|
|
116
|
+
/**
|
|
117
|
+
* Get the color as an _RGBA_ color
|
|
118
|
+
*
|
|
119
|
+
* @returns Current color as an _RGBA_ color
|
|
120
|
+
*/
|
|
121
|
+
get rgba(): RGBAColor;
|
|
122
|
+
/**
|
|
123
|
+
* Set colors and alpha from an _RGBA_ color
|
|
124
|
+
*
|
|
125
|
+
* @param value New _RGBA_ color
|
|
126
|
+
*/
|
|
127
|
+
set rgba(value: RGBAColor);
|
|
128
|
+
/**
|
|
129
|
+
* Get the color as a hex string
|
|
130
|
+
*
|
|
131
|
+
* @param alpha Include alpha channel _(opacity)_? _(defaults to `false`)_
|
|
132
|
+
* @returns Hex color string
|
|
133
|
+
*/
|
|
134
|
+
toHexString(alpha?: boolean): string;
|
|
135
|
+
/**
|
|
136
|
+
* Get the color as an _HSL(A)_ string
|
|
137
|
+
*
|
|
138
|
+
* @param alpha Include alpha channel _(opacity)_? _(defaults to `false`)_
|
|
139
|
+
* @returns _HSL(A)_ color string
|
|
140
|
+
*/
|
|
141
|
+
toHslString(alpha?: boolean): string;
|
|
142
|
+
/**
|
|
143
|
+
* Get the color as an _HWB(A)_ string
|
|
144
|
+
*
|
|
145
|
+
* @param alpha Include alpha channel _(opacity)_? _(defaults to `false`)_
|
|
146
|
+
* @returns _HWB(A)_ color string
|
|
147
|
+
*/
|
|
148
|
+
toHwbString(alpha?: boolean): string;
|
|
149
|
+
/**
|
|
150
|
+
* Get the color as an _RGB(A)_ string
|
|
151
|
+
*
|
|
152
|
+
* @param alpha Include alpha channel _(opacity)_? _(defaults to `false`)_
|
|
153
|
+
* @returns _RGB(A)_ color string
|
|
154
|
+
*/
|
|
155
|
+
toRgbString(alpha?: boolean): string;
|
|
156
|
+
/**
|
|
157
|
+
* Get the color as a hex color string
|
|
158
|
+
*
|
|
159
|
+
* @returns Hex color string
|
|
160
|
+
*/
|
|
161
|
+
toString(): string;
|
|
162
|
+
};
|
|
6
163
|
type ColorWithAlpha = {
|
|
7
164
|
/**
|
|
8
165
|
* Alpha channel _(opacity)_ of the color _(in percentage; 0-100)_
|
|
@@ -67,7 +224,6 @@ type RGBColor = {
|
|
|
67
224
|
red: number;
|
|
68
225
|
};
|
|
69
226
|
type ColorProperty = 'alpha' | keyof HSLColor | keyof HWBColor | keyof RGBColor;
|
|
70
|
-
type ColorSpace = 'hsl' | 'rgb';
|
|
71
227
|
type ColorState = {
|
|
72
228
|
alpha: Alpha;
|
|
73
229
|
hex: string;
|
|
@@ -76,4 +232,4 @@ type ColorState = {
|
|
|
76
232
|
rgb: RGBColor;
|
|
77
233
|
};
|
|
78
234
|
//#endregion
|
|
79
|
-
export { Alpha,
|
|
235
|
+
export { Alpha, Color, ColorProperty, ColorState, HSLAColor, HSLColor, HWBAColor, HWBColor, RGBAColor, RGBColor };
|
|
@@ -3,8 +3,7 @@ import { GenericCallback } from "../models.mjs";
|
|
|
3
3
|
/**
|
|
4
4
|
* A _Memoized_ function instance, caching and retrieving results based on the its parameters _(or a custom cache key)_
|
|
5
5
|
*/
|
|
6
|
-
|
|
7
|
-
#private;
|
|
6
|
+
type Memoized<Callback extends GenericCallback> = {
|
|
8
7
|
/**
|
|
9
8
|
* Maximum cache size
|
|
10
9
|
*
|
|
@@ -17,7 +16,6 @@ declare class Memoized<Callback extends GenericCallback> {
|
|
|
17
16
|
* @returns Current cache size _(or `Number.NaN` if the instance has been destroyed)_
|
|
18
17
|
*/
|
|
19
18
|
get size(): number;
|
|
20
|
-
constructor(callback: Callback, options: Options);
|
|
21
19
|
/**
|
|
22
20
|
* Clear the cache
|
|
23
21
|
*/
|
|
@@ -56,7 +54,7 @@ declare class Memoized<Callback extends GenericCallback> {
|
|
|
56
54
|
* @returns Cached or computed _(then cached)_ result
|
|
57
55
|
*/
|
|
58
56
|
run(...parameters: Parameters<Callback>): ReturnType<Callback>;
|
|
59
|
-
}
|
|
57
|
+
};
|
|
60
58
|
/**
|
|
61
59
|
* Options for a _Memoized_ function
|
|
62
60
|
*/
|
|
@@ -70,10 +68,6 @@ type MemoizedOptions<Callback extends GenericCallback> = {
|
|
|
70
68
|
*/
|
|
71
69
|
cacheSize?: number;
|
|
72
70
|
};
|
|
73
|
-
type Options = {
|
|
74
|
-
cacheKey?: GenericCallback;
|
|
75
|
-
cacheSize: number;
|
|
76
|
-
};
|
|
77
71
|
/**
|
|
78
72
|
* Memoize a function, caching and retrieving results based on the first parameter
|
|
79
73
|
*
|
|
@@ -83,4 +77,4 @@ type Options = {
|
|
|
83
77
|
*/
|
|
84
78
|
declare function memoize<Callback extends GenericCallback>(callback: Callback, options?: MemoizedOptions<Callback>): Memoized<Callback>;
|
|
85
79
|
//#endregion
|
|
86
|
-
export {
|
|
80
|
+
export { Memoized, MemoizedOptions, memoize };
|