@oscarpalmer/atoms 0.203.0 → 0.204.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (77) hide show
  1. package/dist/array/filter.mjs +0 -1
  2. package/dist/array/find.mjs +0 -1
  3. package/dist/array/first.mjs +0 -1
  4. package/dist/array/group-by.mjs +0 -1
  5. package/dist/array/last.mjs +0 -1
  6. package/dist/array/move.mjs +0 -4
  7. package/dist/array/select.mjs +0 -1
  8. package/dist/array/sort.mjs +6 -15
  9. package/dist/array/swap.mjs +0 -1
  10. package/dist/array/to-map.mjs +0 -1
  11. package/dist/array/to-record.mjs +0 -1
  12. package/dist/beacon.mjs +36 -36
  13. package/dist/color/instance.mjs +42 -84
  14. package/dist/color/misc/alpha.d.mts +3 -1
  15. package/dist/color/misc/alpha.mjs +8 -2
  16. package/dist/color/misc/is.mjs +5 -4
  17. package/dist/color/misc/state.d.mts +29 -4
  18. package/dist/color/misc/state.mjs +18 -40
  19. package/dist/color/space/hex.d.mts +5 -1
  20. package/dist/color/space/hex.mjs +21 -2
  21. package/dist/color/space/hsl.d.mts +6 -2
  22. package/dist/color/space/hsl.mjs +25 -4
  23. package/dist/color/space/hwb.d.mts +6 -2
  24. package/dist/color/space/hwb.mjs +24 -3
  25. package/dist/color/space/rgb.d.mts +6 -2
  26. package/dist/color/space/rgb.mjs +41 -20
  27. package/dist/function/limit.mjs +0 -2
  28. package/dist/function/once.mjs +30 -36
  29. package/dist/function/retry.mjs +0 -1
  30. package/dist/index.d.mts +19 -5
  31. package/dist/index.mjs +498 -548
  32. package/dist/internal/{abort.d.mts → aborter.d.mts} +1 -1
  33. package/dist/internal/{abort.mjs → aborter.mjs} +1 -1
  34. package/dist/internal/array/get.mjs +3 -2
  35. package/dist/internal/array/index-of.mjs +0 -1
  36. package/dist/internal/function/assert.d.mts +1 -1
  37. package/dist/internal/function/assert.mjs +0 -7
  38. package/dist/internal/function/limit.mjs +10 -14
  39. package/dist/internal/function/memoize.mjs +22 -20
  40. package/dist/internal/function/work.mjs +0 -2
  41. package/dist/internal/herald.mjs +14 -15
  42. package/dist/internal/result/misc.mjs +2 -5
  43. package/dist/internal/subscription.mjs +24 -22
  44. package/dist/internal/value/compare.d.mts +1 -1
  45. package/dist/internal/value/compare.mjs +0 -5
  46. package/dist/internal/value/equal.d.mts +1 -1
  47. package/dist/internal/value/equal.mjs +4 -12
  48. package/dist/internal/value/handlers.d.mts +1 -1
  49. package/dist/internal/value/handlers.mjs +5 -7
  50. package/dist/internal/value/has.mjs +0 -1
  51. package/dist/internal/value/misc.d.mts +1 -1
  52. package/dist/internal/value/misc.mjs +4 -3
  53. package/dist/internal/value/partial.mjs +2 -1
  54. package/dist/internal/value/set.mjs +2 -1
  55. package/dist/is.d.mts +2 -2
  56. package/dist/is.mjs +2 -2
  57. package/dist/logger.mjs +46 -45
  58. package/dist/promise/delay.mjs +1 -1
  59. package/dist/promise/helpers.mjs +4 -3
  60. package/dist/promise/index.mjs +1 -2
  61. package/dist/promise/misc.d.mts +1 -1
  62. package/dist/promise/models.d.mts +1 -1
  63. package/dist/promise/timed.mjs +1 -1
  64. package/dist/queue.mjs +86 -80
  65. package/dist/result/index.mjs +0 -1
  66. package/dist/result/match.mjs +0 -1
  67. package/dist/result/work/flow.mjs +0 -1
  68. package/dist/result/work/pipe.mjs +0 -1
  69. package/dist/string/fuzzy.mjs +18 -21
  70. package/dist/string/normalize.mjs +2 -3
  71. package/dist/string/template.mjs +2 -3
  72. package/dist/value/clone.d.mts +1 -1
  73. package/dist/value/clone.mjs +4 -12
  74. package/dist/value/freeze.mjs +0 -4
  75. package/dist/value/merge.mjs +5 -7
  76. package/dist/value/transform.mjs +1 -2
  77. package/package.json +2 -2
@@ -1,8 +1,9 @@
1
1
  import { join } from "../../internal/string/misc.mjs";
2
- import { COLOR_ALPHA, COLOR_DEFAULTS, COLOR_EXPRESSION, COLOR_LENGTHS, COLOR_MAX, COLOR_TYPE } from "../constants.mjs";
2
+ import { COLOR_ALPHA, COLOR_DEFAULTS, COLOR_EXPRESSION, COLOR_LENGTHS, COLOR_MAX, COLOR_SYMBOL, COLOR_TYPE } from "../constants.mjs";
3
3
  import { getHexValue, getPercentage } from "../misc/get.mjs";
4
4
  import { isHexColor } from "../misc/is.mjs";
5
5
  import { convertRgbToHsla, convertRgbToHwba } from "./rgb.mjs";
6
+ import { getStateValue, setStateValue } from "../misc/state.mjs";
6
7
  //#region src/color/space/hex.ts
7
8
  function convertHexToRgba(value) {
8
9
  const normalized = getNormalizedHex(value, true);
@@ -29,6 +30,12 @@ function getColorFromHex(state, type) {
29
30
  }
30
31
  return state[type];
31
32
  }
33
+ function getHexColor() {
34
+ return getStateValue(this, COLOR_TYPE.hex, false);
35
+ }
36
+ function getHexaColor() {
37
+ return getStateValue(this, COLOR_TYPE.hex, true);
38
+ }
32
39
  /**
33
40
  * Get the normalized hex color from a value
34
41
  *
@@ -130,5 +137,17 @@ function hexToRgb(value) {
130
137
  function hexToRgba(value) {
131
138
  return convertHexToRgba(value);
132
139
  }
140
+ function setHexValue(value) {
141
+ setHexValueInState(this, value, false);
142
+ }
143
+ function setHexValueInState(instance, value, alpha) {
144
+ const { values } = instance[COLOR_SYMBOL];
145
+ if (!isHexColor(value) || !alpha && value === values.hex) return;
146
+ const normalized = getNormalizedHex(value, true);
147
+ setStateValue(instance, COLOR_TYPE.hex, normalized.slice(0, COLOR_LENGTHS.hexLong), alpha ? normalized.slice(COLOR_LENGTHS.hexLong) : void 0);
148
+ }
149
+ function setHexaValue(value) {
150
+ setHexValueInState(this, value, true);
151
+ }
133
152
  //#endregion
134
- export { getColorFromHex, getNormalizedHex, hexToHsl, hexToHsla, hexToHwb, hexToHwba, hexToRgb, hexToRgba };
153
+ export { getColorFromHex, getHexColor, getHexaColor, getNormalizedHex, hexToHsl, hexToHsla, hexToHwb, hexToHwba, hexToRgb, hexToRgba, setHexValue, setHexaValue };
@@ -1,7 +1,9 @@
1
- import { ColorState, ColorType, HSLAColor, HSLColor, HWBAColor, HWBColor, RGBAColor, RGBColor } from "../models.mjs";
1
+ import { ColorState, ColorType, HSLAColor, HSLColor, HWBAColor, HWBColor, InternalColor, RGBAColor, RGBColor } from "../models.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
- export declare function getHslValue(value: Record<keyof HSLColor, unknown>): HSLColor;
4
+ export declare function getHslValue(this: InternalColor): HSLColor;
5
+ export declare function getHslaValue(this: InternalColor): HSLAColor;
6
+ export declare function getHslValues(value: Record<keyof HSLColor, unknown>): HSLColor;
5
7
  /**
6
8
  * Convert an _HSL(A)_ color to a hex color _(with optional alpha channel, i.e., opacity)_
7
9
  *
@@ -52,4 +54,6 @@ export declare function hslToRgb(hsl: HSLAColor | HSLColor): RGBColor;
52
54
  * @returns _RGBA_ color
53
55
  */
54
56
  export declare function hslToRgba(hsl: HSLAColor | HSLColor): RGBAColor;
57
+ export declare function setHslValue(this: InternalColor, value: unknown): void;
58
+ export declare function setHslaValue(this: InternalColor, value: unknown): void;
55
59
  //#endregion
@@ -3,9 +3,10 @@ import { getAlphaValue } from "../misc/alpha.mjs";
3
3
  import { getDegrees, getHexValue, getPercentage } from "../misc/get.mjs";
4
4
  import { isHslLike } from "../misc/is.mjs";
5
5
  import { convertRgbToHex } from "./rgb.mjs";
6
+ import { getStateValue, setStateValue } from "../misc/state.mjs";
6
7
  //#region src/color/space/hsl.ts
7
8
  function convertHslToHwba(input) {
8
- let { hue, lightness, saturation } = isHslLike(input) ? getHslValue(input) : { ...COLOR_DEFAULTS.hsl };
9
+ let { hue, lightness, saturation } = isHslLike(input) ? getHslValues(input) : { ...COLOR_DEFAULTS.hsl };
9
10
  lightness /= COLOR_MAX.percent;
10
11
  saturation /= COLOR_MAX.percent;
11
12
  const value = lightness + saturation * Math.min(lightness, 1 - lightness);
@@ -20,7 +21,7 @@ function convertHslToHwba(input) {
20
21
  };
21
22
  }
22
23
  function convertHslToRgba(input) {
23
- const hsl = isHslLike(input) ? getHslValue(input) : { ...COLOR_DEFAULTS.hsl };
24
+ const hsl = isHslLike(input) ? getHslValues(input) : { ...COLOR_DEFAULTS.hsl };
24
25
  const hue = hsl.hue % COLOR_MAX.degree;
25
26
  const saturation = hsl.saturation / COLOR_MAX.percent;
26
27
  const lightness = hsl.lightness / COLOR_MAX.percent;
@@ -47,7 +48,13 @@ function getHexyValue(hue, lightness, saturation, value) {
47
48
  const part = (value + hue / 30) % 12;
48
49
  return (lightness - saturation * Math.min(lightness, 1 - lightness) * Math.max(-1, Math.min(part - 3, 9 - part, 1))) * COLOR_MAX.hex;
49
50
  }
50
- function getHslValue(value) {
51
+ function getHslValue() {
52
+ return getStateValue(this, COLOR_TYPE.hsl, false);
53
+ }
54
+ function getHslaValue() {
55
+ return getStateValue(this, COLOR_TYPE.hsl, true);
56
+ }
57
+ function getHslValues(value) {
51
58
  return {
52
59
  hue: getDegrees(value.hue),
53
60
  saturation: getPercentage(value.saturation),
@@ -124,5 +131,19 @@ function hslToRgb(hsl) {
124
131
  function hslToRgba(hsl) {
125
132
  return convertHslToRgba(hsl);
126
133
  }
134
+ function setHslValue(value) {
135
+ setHSLValueInState(this, value, false);
136
+ }
137
+ function setHSLValueInState(instance, value, alpha) {
138
+ if (!isHslLike(value)) return;
139
+ setStateValue(instance, COLOR_TYPE.hsl, {
140
+ hue: getDegrees(value.hue),
141
+ saturation: getPercentage(value.saturation),
142
+ lightness: getPercentage(value.lightness)
143
+ }, alpha ? value.alpha : void 0);
144
+ }
145
+ function setHslaValue(value) {
146
+ setHSLValueInState(this, value, true);
147
+ }
127
148
  //#endregion
128
- export { getColorFromHsl, getHslValue, hslToHex, hslToHwb, hslToHwba, hslToRgb, hslToRgba };
149
+ export { getColorFromHsl, getHslValue, getHslValues, getHslaValue, hslToHex, hslToHwb, hslToHwba, hslToRgb, hslToRgba, setHslValue, setHslaValue };
@@ -1,8 +1,10 @@
1
- import { ColorState, ColorType, HSLAColor, HSLColor, HWBAColor, HWBColor, RGBAColor, RGBColor } from "../models.mjs";
1
+ import { ColorState, ColorType, HSLAColor, HSLColor, HWBAColor, HWBColor, InternalColor, RGBAColor, RGBColor } from "../models.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]>;
5
- export declare function getHwbValue(value: Record<keyof HWBColor, unknown>): HWBColor;
5
+ export declare function getHwbValue(this: InternalColor): HWBColor;
6
+ export declare function getHwbaValue(this: InternalColor): HWBAColor;
7
+ export declare function getHwbValues(value: Record<keyof HWBColor, unknown>): HWBColor;
6
8
  /**
7
9
  * Convert an _HWB(A)_ color to a hex color _(with optional alpha channel, i.e., opacity)_
8
10
  *
@@ -49,4 +51,6 @@ export declare function hwbToRgb(hwb: HWBAColor | HWBColor): RGBColor;
49
51
  * @returns _RGBA_ color
50
52
  */
51
53
  export declare function hwbToRgba(hwb: HWBAColor | HWBColor): RGBAColor;
54
+ export declare function setHwbValue(this: InternalColor, value: unknown): void;
55
+ export declare function setHwbaValue(this: InternalColor, value: unknown): void;
52
56
  //#endregion
@@ -4,9 +4,10 @@ import { getDegrees, getPercentage } from "../misc/get.mjs";
4
4
  import { isHwbLike } from "../misc/is.mjs";
5
5
  import { rgbToHex } from "./rgb.mjs";
6
6
  import { hslToRgb, hslToRgba } from "./hsl.mjs";
7
+ import { getStateValue, setStateValue } from "../misc/state.mjs";
7
8
  //#region src/color/space/hwb.ts
8
9
  function convertHwbToHsl(input) {
9
- let { blackness, hue, whiteness } = isHwbLike(input) ? getHwbValue(input) : COLOR_DEFAULTS.hwb;
10
+ let { blackness, hue, whiteness } = isHwbLike(input) ? getHwbValues(input) : COLOR_DEFAULTS.hwb;
10
11
  blackness /= COLOR_MAX.percent;
11
12
  whiteness /= COLOR_MAX.percent;
12
13
  if (blackness + whiteness > 1) {
@@ -39,7 +40,13 @@ function getHwbSaturation(blackness, whiteness, lightness) {
39
40
  if (hue <= 0) return 0;
40
41
  return hue / Math.min(2 * lightness, 2 - 2 * lightness);
41
42
  }
42
- function getHwbValue(value) {
43
+ function getHwbValue() {
44
+ return getStateValue(this, COLOR_TYPE.hwb, false);
45
+ }
46
+ function getHwbaValue() {
47
+ return getStateValue(this, COLOR_TYPE.hwb, true);
48
+ }
49
+ function getHwbValues(value) {
43
50
  return {
44
51
  hue: getDegrees(value.hue),
45
52
  whiteness: getPercentage(value.whiteness),
@@ -107,5 +114,19 @@ function hwbToRgb(hwb) {
107
114
  function hwbToRgba(hwb) {
108
115
  return hslToRgba(hwbToHsla(hwb));
109
116
  }
117
+ function setHwbValue(value) {
118
+ setHwbColorValueInState(this, value, false);
119
+ }
120
+ function setHwbColorValueInState(instance, value, alpha) {
121
+ if (!isHwbLike(value)) return;
122
+ setStateValue(instance, COLOR_TYPE.hwb, {
123
+ hue: getDegrees(value.hue),
124
+ whiteness: getPercentage(value.whiteness),
125
+ blackness: getPercentage(value.blackness)
126
+ }, alpha ? value.alpha : void 0);
127
+ }
128
+ function setHwbaValue(value) {
129
+ setHwbColorValueInState(this, value, true);
130
+ }
110
131
  //#endregion
111
- export { convertHwbToHsl, getColorFromHwb, getHwbValue, hwbToHex, hwbToHsl, hwbToHsla, hwbToRgb, hwbToRgba };
132
+ export { convertHwbToHsl, getColorFromHwb, getHwbValue, getHwbValues, getHwbaValue, hwbToHex, hwbToHsl, hwbToHsla, hwbToRgb, hwbToRgba, setHwbValue, setHwbaValue };
@@ -1,10 +1,12 @@
1
- import { ColorState, ColorType, HSLAColor, HSLColor, HWBAColor, HWBColor, RGBAColor, RGBColor } from "../models.mjs";
1
+ import { ColorState, ColorType, HSLAColor, HSLColor, HWBAColor, HWBColor, InternalColor, RGBAColor, RGBColor } from "../models.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;
5
5
  export declare function convertRgbToHwba(value: unknown): HWBAColor;
6
6
  export declare function getColorFromRgb<Type extends ColorType>(state: ColorState, type: Type): NonNullable<ColorState[Type]>;
7
- export declare function getRgbValue(value: Record<keyof RGBColor, unknown>): RGBColor;
7
+ export declare function getRgbColor(this: InternalColor): RGBColor;
8
+ export declare function getRgbaColor(this: InternalColor): RGBAColor;
9
+ export declare function getRgbValues(value: Record<keyof RGBColor, unknown>): RGBColor;
8
10
  /**
9
11
  * Convert an _RGB(A)_ color to a hex color _(with optional alpha channel, i.e., opacity)_
10
12
  *
@@ -58,4 +60,6 @@ export declare function rgbToHwb(rgb: RGBAColor | RGBColor): HWBColor;
58
60
  * @returns _HWBA_ color
59
61
  */
60
62
  export declare function rgbToHwba(rgb: RGBAColor | RGBColor): HWBAColor;
63
+ export declare function setRgbValue(this: InternalColor, value: unknown): void;
64
+ export declare function setRgbaValue(this: InternalColor, value: unknown): void;
61
65
  //#endregion
@@ -3,6 +3,7 @@ import { COLOR_DEFAULTS, COLOR_MAX, COLOR_TYPE } from "../constants.mjs";
3
3
  import { getAlpha, getAlphaValue } from "../misc/alpha.mjs";
4
4
  import { getHexValue } from "../misc/get.mjs";
5
5
  import { isRgbLike } from "../misc/is.mjs";
6
+ import { getStateValue, setStateValue } from "../misc/state.mjs";
6
7
  //#region src/color/space/rgb.ts
7
8
  function convertRgbToHex(rgb, alpha) {
8
9
  const hex = `${join([
@@ -18,7 +19,7 @@ function convertRgbToHex(rgb, alpha) {
18
19
  return `${hex}${a}`;
19
20
  }
20
21
  function convertRgbToHsla(value) {
21
- const values = getRgbValues(isRgbLike(value) ? getRgbValue(value) : { ...COLOR_DEFAULTS.rgb });
22
+ const values = getRgbCalculationValues(isRgbLike(value) ? getRgbValues(value) : { ...COLOR_DEFAULTS.rgb });
22
23
  const { delta, max, min } = values;
23
24
  const lightness = (min + max) / 2;
24
25
  let hue = 0;
@@ -36,7 +37,7 @@ function convertRgbToHsla(value) {
36
37
  };
37
38
  }
38
39
  function convertRgbToHwba(value) {
39
- const values = getRgbValues(isRgbLike(value) ? getRgbValue(value) : { ...COLOR_DEFAULTS.rgb });
40
+ const values = getRgbCalculationValues(isRgbLike(value) ? getRgbValues(value) : { ...COLOR_DEFAULTS.rgb });
40
41
  const { delta, max, min } = values;
41
42
  let hue = 0;
42
43
  if (delta !== 0) {
@@ -62,22 +63,7 @@ function getColorFromRgb(state, type) {
62
63
  }
63
64
  return state[type];
64
65
  }
65
- function getRgbHue(values) {
66
- const { blue, delta, green, max, red } = values;
67
- switch (max) {
68
- case blue: return (red - green) / delta + 4;
69
- case green: return (blue - red) / delta + 2;
70
- default: return (green - blue) / delta + (green < blue ? 6 : 0);
71
- }
72
- }
73
- function getRgbValue(value) {
74
- return {
75
- blue: getHexValue(value.blue),
76
- green: getHexValue(value.green),
77
- red: getHexValue(value.red)
78
- };
79
- }
80
- function getRgbValues(rgb) {
66
+ function getRgbCalculationValues(rgb) {
81
67
  const blue = rgb.blue / COLOR_MAX.hex;
82
68
  const green = rgb.green / COLOR_MAX.hex;
83
69
  const red = rgb.red / COLOR_MAX.hex;
@@ -92,6 +78,27 @@ function getRgbValues(rgb) {
92
78
  red
93
79
  };
94
80
  }
81
+ function getRgbColor() {
82
+ return getStateValue(this, COLOR_TYPE.rgb, false);
83
+ }
84
+ function getRgbaColor() {
85
+ return getStateValue(this, COLOR_TYPE.rgb, true);
86
+ }
87
+ function getRgbHue(values) {
88
+ const { blue, delta, green, max, red } = values;
89
+ switch (max) {
90
+ case blue: return (red - green) / delta + 4;
91
+ case green: return (blue - red) / delta + 2;
92
+ default: return (green - blue) / delta + (green < blue ? 6 : 0);
93
+ }
94
+ }
95
+ function getRgbValues(value) {
96
+ return {
97
+ blue: getHexValue(value.blue),
98
+ green: getHexValue(value.green),
99
+ red: getHexValue(value.red)
100
+ };
101
+ }
95
102
  /**
96
103
  * Convert an _RGB(A)_ color to a hex color _(with optional alpha channel, i.e., opacity)_
97
104
  *
@@ -102,7 +109,7 @@ function getRgbValues(rgb) {
102
109
  * @returns Hex color string
103
110
  */
104
111
  function rgbToHex(rgb, alpha) {
105
- return convertRgbToHex(isRgbLike(rgb) ? getRgbValue(rgb) : { ...COLOR_DEFAULTS.rgb }, alpha ?? false);
112
+ return convertRgbToHex(isRgbLike(rgb) ? getRgbValues(rgb) : { ...COLOR_DEFAULTS.rgb }, alpha ?? false);
106
113
  }
107
114
  /**
108
115
  * Convert an _RGB(A)_ color to an _HSL_ color
@@ -166,5 +173,19 @@ function rgbToHwb(rgb) {
166
173
  function rgbToHwba(rgb) {
167
174
  return convertRgbToHwba(rgb);
168
175
  }
176
+ function setRgbValue(value) {
177
+ setRgbColorValueInState(this, value, false);
178
+ }
179
+ function setRgbColorValueInState(instance, value, alpha) {
180
+ if (!isRgbLike(value)) return;
181
+ setStateValue(instance, COLOR_TYPE.rgb, {
182
+ red: getHexValue(value.red),
183
+ green: getHexValue(value.green),
184
+ blue: getHexValue(value.blue)
185
+ }, alpha ? value.alpha : void 0);
186
+ }
187
+ function setRgbaValue(value) {
188
+ setRgbColorValueInState(this, value, true);
189
+ }
169
190
  //#endregion
170
- export { convertRgbToHex, convertRgbToHsla, convertRgbToHwba, getColorFromRgb, getRgbValue, rgbToHex, rgbToHsl, rgbToHsla, rgbToHwb, rgbToHwba };
191
+ export { convertRgbToHex, convertRgbToHsla, convertRgbToHwba, getColorFromRgb, getRgbColor, getRgbValues, getRgbaColor, rgbToHex, rgbToHsl, rgbToHsla, rgbToHwb, rgbToHwba, setRgbValue, setRgbaValue };
@@ -54,7 +54,5 @@ function throttle(callback, time) {
54
54
  }
55
55
  debounce.async = asyncDebounce;
56
56
  throttle.async = asyncThrottle;
57
- Object.defineProperty(debounce, "async", { value: asyncDebounce });
58
- Object.defineProperty(throttle, "async", { value: asyncThrottle });
59
57
  //#endregion
60
58
  export { asyncDebounce, asyncThrottle, debounce, throttle };
@@ -4,7 +4,7 @@ const ONCE_NAME_ASYNC = "asyncOnce";
4
4
  const ONCE_NAME_SYNC = "once";
5
5
  const ONCE_PROPERTY = "$once";
6
6
  function AsyncOnce(callback) {
7
- Object.defineProperty(this, ONCE_SYMBOL, { value: {
7
+ this[ONCE_SYMBOL] = {
8
8
  callback,
9
9
  called: false,
10
10
  cleared: false,
@@ -12,61 +12,49 @@ function AsyncOnce(callback) {
12
12
  finished: false,
13
13
  items: [],
14
14
  value: void 0
15
- } });
15
+ };
16
16
  }
17
+ AsyncOnce.prototype[ONCE_PROPERTY] = ONCE_NAME_ASYNC;
18
+ AsyncOnce.prototype.clear = clearOnce;
19
+ AsyncOnce.prototype.run = runOnceAsync;
17
20
  Object.defineProperties(AsyncOnce.prototype, {
18
- [ONCE_PROPERTY]: { value: ONCE_NAME_ASYNC },
19
21
  called: {
20
22
  enumerable: true,
21
- get() {
22
- return this[ONCE_SYMBOL].called;
23
- }
23
+ get: getOnceCalled
24
24
  },
25
- clear: { value: clearOnce },
26
25
  cleared: {
27
26
  enumerable: true,
28
- get() {
29
- return this[ONCE_SYMBOL].cleared;
30
- }
27
+ get: getOnceCleared
31
28
  },
32
29
  error: {
33
30
  enumerable: true,
34
- get() {
35
- return this[ONCE_SYMBOL].error;
36
- }
31
+ get: getAsyncOnceError
37
32
  },
38
33
  finished: {
39
34
  enumerable: true,
40
- get() {
41
- return this[ONCE_SYMBOL].finished;
42
- }
43
- },
44
- run: { value: runOnceAsync }
35
+ get: getAsyncOnceFinished
36
+ }
45
37
  });
46
38
  function Once(callback) {
47
- Object.defineProperty(this, ONCE_SYMBOL, { value: {
39
+ this[ONCE_SYMBOL] = {
48
40
  callback,
49
41
  called: false,
50
42
  cleared: false,
51
43
  value: void 0
52
- } });
44
+ };
53
45
  }
46
+ Once.prototype[ONCE_PROPERTY] = ONCE_NAME_SYNC;
47
+ Once.prototype.clear = clearOnce;
48
+ Once.prototype.run = runOnce;
54
49
  Object.defineProperties(Once.prototype, {
55
- [ONCE_PROPERTY]: { value: ONCE_NAME_SYNC },
56
- clear: { value: clearOnce },
57
50
  called: {
58
51
  enumerable: true,
59
- get() {
60
- return this[ONCE_SYMBOL].called;
61
- }
52
+ get: getOnceCalled
62
53
  },
63
54
  cleared: {
64
55
  enumerable: true,
65
- get() {
66
- return this[ONCE_SYMBOL].cleared;
67
- }
68
- },
69
- run: { value: runOnce }
56
+ get: getOnceCleared
57
+ }
70
58
  });
71
59
  /**
72
60
  * Create an asynchronous function that can only be called once, rejecting or resolving the same result on subsequent calls
@@ -87,6 +75,18 @@ function clearOnce() {
87
75
  state.cleared = true;
88
76
  state.value = void 0;
89
77
  }
78
+ function getAsyncOnceError() {
79
+ return this[ONCE_SYMBOL].error;
80
+ }
81
+ function getAsyncOnceFinished() {
82
+ return this[ONCE_SYMBOL].finished;
83
+ }
84
+ function getOnceCalled() {
85
+ return this[ONCE_SYMBOL].called;
86
+ }
87
+ function getOnceCleared() {
88
+ return this[ONCE_SYMBOL].cleared;
89
+ }
90
90
  function handleOnceResult(state, value, error) {
91
91
  state.error = error;
92
92
  state.finished = true;
@@ -168,11 +168,5 @@ asyncOnce.is = isAsyncOnce;
168
168
  once.async = asyncOnce;
169
169
  once.is = isOnce;
170
170
  once.isAsync = isAsyncOnce;
171
- Object.defineProperty(asyncOnce, "is", { value: isAsyncOnce });
172
- Object.defineProperties(once, {
173
- async: { value: asyncOnce },
174
- is: { value: isOnce },
175
- isAsync: { value: isAsyncOnce }
176
- });
177
171
  //#endregion
178
172
  export { asyncOnce, isAsyncOnce, isOnce, once };
@@ -83,6 +83,5 @@ const RETRY_ERROR_NAME = "RetryError";
83
83
  const RETRY_MESSAGE_EXPECTATION = "Retry expected a function";
84
84
  const RETRY_MESSAGE_FAILED = "Retry failed";
85
85
  retry.async = asyncRetry;
86
- Object.defineProperty(retry, "async", { value: asyncRetry });
87
86
  //#endregion
88
87
  export { RetryError, retry };
package/dist/index.d.mts CHANGED
@@ -4019,7 +4019,7 @@ export declare function assertIs<Value>(condition: (value: unknown) => value is
4019
4019
  * @param error Error constructor _(defaults to `Error`)_
4020
4020
  * @returns _Asserter_
4021
4021
  */
4022
- export declare function assertProperty<Value extends PlainObject, Path extends NestedKeys<Value>, Asserted = NestedPick<Value, Path>>(path: Path, condition: (value: NestedValue<Value, Path>) => boolean, message: string, error?: ErrorConstructor): Asserter<Asserted>;
4022
+ export declare function assertProperty<Value extends PlainObject, Path extends NestedKeys<Value>>(path: Path, condition: (value: NestedValue<Value, Path>) => boolean, message: string, error?: ErrorConstructor): Asserter<NestedPick<Value, Path>>;
4023
4023
  //#endregion
4024
4024
  //#region src/internal/function/memoize.d.ts
4025
4025
  /**
@@ -4260,7 +4260,7 @@ export declare namespace compare {
4260
4260
  var deregister: typeof deregisterComparator;
4261
4261
  var handler: {
4262
4262
  base: {
4263
- handlers: WeakMap<Constructor, string | GenericCallback>;
4263
+ handlers: WeakMap<WeakKey, string | GenericCallback>;
4264
4264
  options: {
4265
4265
  callback: GenericCallback;
4266
4266
  method?: string;
@@ -4388,7 +4388,7 @@ export declare namespace equal {
4388
4388
  var deregister: typeof deregisterEqualizer;
4389
4389
  var handler: {
4390
4390
  base: {
4391
- handlers: WeakMap<Constructor, string | GenericCallback>;
4391
+ handlers: WeakMap<WeakKey, string | GenericCallback>;
4392
4392
  options: {
4393
4393
  callback: GenericCallback;
4394
4394
  method?: string;
@@ -4596,7 +4596,7 @@ export declare function setValue<Data extends PlainObject, Path extends NestedKe
4596
4596
  */
4597
4597
  export declare function setValue<Data extends PlainObject>(data: Data, path: string, value: unknown, ignoreCase?: boolean): Data;
4598
4598
  //#endregion
4599
- //#region src/internal/abort.d.ts
4599
+ //#region src/internal/aborter.d.ts
4600
4600
  type Aborter = {
4601
4601
  callback: GenericCallback;
4602
4602
  signal: AbortSignal;
@@ -5882,7 +5882,7 @@ export declare namespace clone {
5882
5882
  var deregister: typeof deregisterCloner;
5883
5883
  var handlers: {
5884
5884
  base: {
5885
- handlers: WeakMap<Constructor, string | GenericCallback>;
5885
+ handlers: WeakMap<WeakKey, string | GenericCallback>;
5886
5886
  options: {
5887
5887
  callback: GenericCallback;
5888
5888
  method?: string;
@@ -7451,6 +7451,13 @@ export declare function isNonPlainObject<Value>(value: Value): value is Exclude<
7451
7451
  * @returns `true` if the value is not a primitive value, otherwise `false`
7452
7452
  */
7453
7453
  export declare function isNonPrimitive<Value>(value: Value): value is Exclude<Value, Primitive>;
7454
+ /**
7455
+ * Is the value not a template strings array?
7456
+ *
7457
+ * @param value Value to check
7458
+ * @returns `true` if the value is not a `TemplateStringsArray`, otherwise `false`
7459
+ */
7460
+ export declare function isNonTemplateStringsArray<Value>(value: Value): value is Exclude<Value, TemplateStringsArray>;
7454
7461
  /**
7455
7462
  * Is the value not a typed array?
7456
7463
  *
@@ -7479,6 +7486,13 @@ export declare function isPlainObject(value: unknown): value is PlainObject;
7479
7486
  * @returns `true` if the value is a primitive value, otherwise `false`
7480
7487
  */
7481
7488
  export declare function isPrimitive(value: unknown): value is Primitive;
7489
+ /**
7490
+ * Is the value a template strings array?
7491
+ *
7492
+ * @param value Value to check
7493
+ * @returns `true` if the value is a `TemplateStringsArray`, otherwise `false`
7494
+ */
7495
+ export declare function isTemplateStringsArray(value: unknown): value is TemplateStringsArray;
7482
7496
  /**
7483
7497
  * Is the value a typed array?
7484
7498
  *