nhb-toolbox 4.10.10 → 4.10.16
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/cjs/colors/Color.js +23 -22
- package/dist/cjs/colors/convert.js +8 -7
- package/dist/cjs/colors/helpers.js +1 -23
- package/dist/cjs/colors/utils.js +39 -0
- package/dist/cjs/date/utils.js +3 -15
- package/dist/cjs/index.js +55 -49
- package/dist/cjs/object/sanitize.js +6 -5
- package/dist/dts/colors/Color.d.ts +4 -4
- package/dist/dts/colors/Color.d.ts.map +1 -1
- package/dist/dts/colors/convert.d.ts.map +1 -1
- package/dist/dts/colors/helpers.d.ts +1 -17
- package/dist/dts/colors/helpers.d.ts.map +1 -1
- package/dist/dts/colors/types.d.ts +4 -5
- package/dist/dts/colors/types.d.ts.map +1 -1
- package/dist/dts/colors/utils.d.ts +22 -0
- package/dist/dts/colors/utils.d.ts.map +1 -0
- package/dist/dts/date/utils.d.ts +2 -1
- package/dist/dts/date/utils.d.ts.map +1 -1
- package/dist/dts/index.d.ts +3 -2
- package/dist/dts/index.d.ts.map +1 -1
- package/dist/dts/object/convert.d.ts +4 -2
- package/dist/dts/object/convert.d.ts.map +1 -1
- package/dist/dts/object/sanitize.d.ts +5 -3
- package/dist/dts/object/sanitize.d.ts.map +1 -1
- package/dist/dts/object/types.d.ts +0 -22
- package/dist/dts/object/types.d.ts.map +1 -1
- package/dist/dts/string/types.d.ts +0 -5
- package/dist/dts/string/types.d.ts.map +1 -1
- package/dist/dts/types/index.d.ts +2 -33
- package/dist/dts/types/index.d.ts.map +1 -1
- package/dist/esm/colors/Color.js +24 -23
- package/dist/esm/colors/convert.js +9 -8
- package/dist/esm/colors/helpers.js +0 -20
- package/dist/esm/colors/utils.js +34 -0
- package/dist/esm/date/utils.js +3 -15
- package/dist/esm/index.js +3 -2
- package/dist/esm/object/sanitize.js +6 -5
- package/package.json +1 -1
package/dist/cjs/colors/Color.js
CHANGED
|
@@ -5,6 +5,7 @@ const convert_1 = require("./convert");
|
|
|
5
5
|
const css_colors_1 = require("./css-colors");
|
|
6
6
|
const helpers_1 = require("./helpers");
|
|
7
7
|
const random_1 = require("./random");
|
|
8
|
+
const utils_1 = require("./utils");
|
|
8
9
|
const hsl = (0, random_1.generateRandomHSLColor)();
|
|
9
10
|
const { hex, rgb } = (0, convert_1.convertColorCode)(hsl);
|
|
10
11
|
/**
|
|
@@ -84,8 +85,8 @@ class Color {
|
|
|
84
85
|
const colors = this.#convertColorToOthers(color);
|
|
85
86
|
if ('hex8' in colors) {
|
|
86
87
|
// Extract alpha color values (Hex8, RGBA, HSLA)
|
|
87
|
-
const rgbaValues = (0,
|
|
88
|
-
const hslaValues = (0,
|
|
88
|
+
const rgbaValues = (0, utils_1.extractAlphaColorValues)(colors.rgba);
|
|
89
|
+
const hslaValues = (0, utils_1.extractAlphaColorValues)(colors.hsla);
|
|
89
90
|
this.hex = colors.hex8.toUpperCase().slice(0, 7);
|
|
90
91
|
this.hex8 = colors.hex8.toUpperCase();
|
|
91
92
|
this.rgb = `rgb(${rgbaValues[0]}, ${rgbaValues[1]}, ${rgbaValues[2]})`;
|
|
@@ -95,8 +96,8 @@ class Color {
|
|
|
95
96
|
}
|
|
96
97
|
else {
|
|
97
98
|
// Extract solid color values (Hex, RGB, HSL)
|
|
98
|
-
const rgbValues = (0,
|
|
99
|
-
const hslValues = (0,
|
|
99
|
+
const rgbValues = (0, utils_1.extractSolidColorValues)(colors.rgb);
|
|
100
|
+
const hslValues = (0, utils_1.extractSolidColorValues)(colors.hsl);
|
|
100
101
|
this.hex = colors.hex.toUpperCase();
|
|
101
102
|
this.hex8 =
|
|
102
103
|
`${colors.hex.toUpperCase()}${(0, helpers_1._convertOpacityToHex)(100)}`;
|
|
@@ -108,8 +109,8 @@ class Color {
|
|
|
108
109
|
}
|
|
109
110
|
}
|
|
110
111
|
else {
|
|
111
|
-
const rgbValues = (0,
|
|
112
|
-
const hslValues = (0,
|
|
112
|
+
const rgbValues = (0, utils_1.extractSolidColorValues)(rgb);
|
|
113
|
+
const hslValues = (0, utils_1.extractSolidColorValues)(hsl);
|
|
113
114
|
// Generate random colors
|
|
114
115
|
this.hex = hex.toUpperCase();
|
|
115
116
|
this.hex8 =
|
|
@@ -151,8 +152,8 @@ class Color {
|
|
|
151
152
|
const validOpacity = Math.min(100, Math.max(0, opacity));
|
|
152
153
|
const alphaHex = (0, helpers_1._convertOpacityToHex)(opacity);
|
|
153
154
|
const alphaDecimal = validOpacity / 100;
|
|
154
|
-
const rgbValues = (0,
|
|
155
|
-
const hslValues = (0,
|
|
155
|
+
const rgbValues = (0, utils_1.extractSolidColorValues)(this.rgb);
|
|
156
|
+
const hslValues = (0, utils_1.extractSolidColorValues)(this.hsl);
|
|
156
157
|
return Color.#fromParts({
|
|
157
158
|
hex: this.hex.slice(0, 7).toUpperCase(),
|
|
158
159
|
hex8: `${this.hex.slice(0, 7)}${alphaHex}`.toUpperCase(),
|
|
@@ -168,7 +169,7 @@ class Color {
|
|
|
168
169
|
* @returns A new `Color` instance with the modified darkness.
|
|
169
170
|
*/
|
|
170
171
|
applyDarkness(percent) {
|
|
171
|
-
const [h, s, l, a] = (0,
|
|
172
|
+
const [h, s, l, a] = (0, utils_1.extractAlphaColorValues)(this.hsla);
|
|
172
173
|
const newL = Math.max(0, l - percent);
|
|
173
174
|
const newHSL = `hsl(${h}, ${s}%, ${newL}%)`;
|
|
174
175
|
return new Color(newHSL).applyOpacity((a * 100));
|
|
@@ -179,7 +180,7 @@ class Color {
|
|
|
179
180
|
* @returns A new `Color` instance with the modified lightness.
|
|
180
181
|
*/
|
|
181
182
|
applyBrightness(percent) {
|
|
182
|
-
const [h, s, l, a] = (0,
|
|
183
|
+
const [h, s, l, a] = (0, utils_1.extractAlphaColorValues)(this.hsla);
|
|
183
184
|
const newL = Math.min(100, l + percent);
|
|
184
185
|
const newHSL = `hsl(${h}, ${s}%, ${newL}%)`;
|
|
185
186
|
return new Color(newHSL).applyOpacity((a * 100));
|
|
@@ -190,7 +191,7 @@ class Color {
|
|
|
190
191
|
* @returns A new `Color` instance with the modified saturation.
|
|
191
192
|
*/
|
|
192
193
|
applyDullness(percent) {
|
|
193
|
-
const [h, s, l, a] = (0,
|
|
194
|
+
const [h, s, l, a] = (0, utils_1.extractAlphaColorValues)(this.hsla);
|
|
194
195
|
const newS = Math.max(0, s - percent);
|
|
195
196
|
const newHSL = `hsl(${h}, ${newS}%, ${l}%)`;
|
|
196
197
|
return new Color(newHSL).applyOpacity((a * 100));
|
|
@@ -202,7 +203,7 @@ class Color {
|
|
|
202
203
|
* @returns A new `Color` instance shifted toward white.
|
|
203
204
|
*/
|
|
204
205
|
applyWhiteShade(percent) {
|
|
205
|
-
const [h, s, l, a] = (0,
|
|
206
|
+
const [h, s, l, a] = (0, utils_1.extractAlphaColorValues)(this.hsla);
|
|
206
207
|
// Cap values to avoid overshooting
|
|
207
208
|
const newS = Math.max(0, s - (s * percent) / 100);
|
|
208
209
|
const newL = Math.min(100, l + ((100 - l) * percent) / 100);
|
|
@@ -223,9 +224,9 @@ class Color {
|
|
|
223
224
|
*/
|
|
224
225
|
blendWith(other, weight = 0.5) {
|
|
225
226
|
const w = Math.max(0, Math.min(1, weight));
|
|
226
|
-
const converted = new Color(other);
|
|
227
|
-
const [r1, b1, g1, a1] = (0,
|
|
228
|
-
const [r2, b2, g2, a2] = (0,
|
|
227
|
+
const converted = Color.isCSSColor(other) ? new Color(other) : new Color(other);
|
|
228
|
+
const [r1, b1, g1, a1] = (0, utils_1.extractAlphaColorValues)(this.rgba);
|
|
229
|
+
const [r2, b2, g2, a2] = (0, utils_1.extractAlphaColorValues)(converted.rgba);
|
|
229
230
|
const alpha = Math.round((a1 * (1 - w) + a2 * w) * 100) / 100;
|
|
230
231
|
const blendChannel = (c1, c2) => {
|
|
231
232
|
return Math.round((c1 * a1 * (1 - w) + c2 * a2 * w) / alpha);
|
|
@@ -242,9 +243,9 @@ class Color {
|
|
|
242
243
|
* @returns A number representing the contrast ratio (rounded to 2 decimal places).
|
|
243
244
|
*/
|
|
244
245
|
contrastRatio(other) {
|
|
245
|
-
const newColor = new Color(other);
|
|
246
|
+
const newColor = Color.isCSSColor(other) ? new Color(other) : new Color(other);
|
|
246
247
|
const luminance = (rgb) => {
|
|
247
|
-
const [r, g, b] = (0,
|
|
248
|
+
const [r, g, b] = (0, utils_1.extractSolidColorValues)(rgb).map((v) => {
|
|
248
249
|
const c = v / 255;
|
|
249
250
|
return c <= 0.03928 ?
|
|
250
251
|
c / 12.92
|
|
@@ -264,7 +265,7 @@ class Color {
|
|
|
264
265
|
* @returns A new Color that is the complement of the current color.
|
|
265
266
|
*/
|
|
266
267
|
getComplementaryColor() {
|
|
267
|
-
const [h, s, l, a] = (0,
|
|
268
|
+
const [h, s, l, a] = (0, utils_1.extractAlphaColorValues)(this.hsla);
|
|
268
269
|
const newHue = (h + 180) % 360;
|
|
269
270
|
const newHSL = `hsl(${newHue}, ${s}%, ${l}%)`;
|
|
270
271
|
return new Color(newHSL).applyOpacity((a * 100));
|
|
@@ -275,7 +276,7 @@ class Color {
|
|
|
275
276
|
* @returns An array of three Color instances: [base, left, right].
|
|
276
277
|
*/
|
|
277
278
|
getAnalogousColors() {
|
|
278
|
-
const [h, s, l, a] = (0,
|
|
279
|
+
const [h, s, l, a] = (0, utils_1.extractAlphaColorValues)(this.hsla);
|
|
279
280
|
const left = `hsl(${(h + 330) % 360}, ${s}%, ${l}%)`;
|
|
280
281
|
const right = `hsl(${(h + 30) % 360}, ${s}%, ${l}%)`;
|
|
281
282
|
const analogous = [this, new Color(left), new Color(right)];
|
|
@@ -287,7 +288,7 @@ class Color {
|
|
|
287
288
|
* @returns An array of three Color instances: [base, triad1, triad2].
|
|
288
289
|
*/
|
|
289
290
|
getTriadColors() {
|
|
290
|
-
const [h, s, l, a] = (0,
|
|
291
|
+
const [h, s, l, a] = (0, utils_1.extractAlphaColorValues)(this.hsla);
|
|
291
292
|
const c1 = `hsl(${(h + 120) % 360}, ${s}%, ${l}%)`;
|
|
292
293
|
const c2 = `hsl(${(h + 240) % 360}, ${s}%, ${l}%)`;
|
|
293
294
|
const triad = [this, new Color(c1), new Color(c2)];
|
|
@@ -299,7 +300,7 @@ class Color {
|
|
|
299
300
|
* @returns An array of four Color instances: [base, tetrad1, tetrad2, tetrad3].
|
|
300
301
|
*/
|
|
301
302
|
getTetradColors() {
|
|
302
|
-
const [h, s, l, a] = (0,
|
|
303
|
+
const [h, s, l, a] = (0, utils_1.extractAlphaColorValues)(this.hsla);
|
|
303
304
|
const c1 = `hsl(${(h + 90) % 360}, ${s}%, ${l}%)`;
|
|
304
305
|
const c2 = `hsl(${(h + 180) % 360}, ${s}%, ${l}%)`;
|
|
305
306
|
const c3 = `hsl(${(h + 270) % 360}, ${s}%, ${l}%)`;
|
|
@@ -324,7 +325,7 @@ class Color {
|
|
|
324
325
|
* @returns `true` if light, `false` if dark.
|
|
325
326
|
*/
|
|
326
327
|
isLightColor() {
|
|
327
|
-
const [r, g, b] = (0,
|
|
328
|
+
const [r, g, b] = (0, utils_1.extractSolidColorValues)(this.rgb);
|
|
328
329
|
const brightness = (r * 299 + g * 587 + b * 114) / 1000;
|
|
329
330
|
return brightness > 127.5;
|
|
330
331
|
}
|
|
@@ -3,6 +3,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
3
3
|
exports.convertHex8ToHsla = exports.convertHslaToHex8 = exports.convertHex8ToRgba = exports.convertRgbaToHsla = exports.convertHslaToRgba = exports.convertRgbaToHex8 = exports.convertRgbToRgba = exports.convertHexToRgb = exports.convertRgbToHex = exports.convertHexToHsl = exports.convertHslToHex = exports.convertRgbToHsl = exports.convertHslToRgb = void 0;
|
|
4
4
|
exports.convertColorCode = convertColorCode;
|
|
5
5
|
const helpers_1 = require("./helpers");
|
|
6
|
+
const utils_1 = require("./utils");
|
|
6
7
|
/**
|
|
7
8
|
* * Converts HSL to RGB color format.
|
|
8
9
|
*
|
|
@@ -196,7 +197,7 @@ const convertHslaToRgba = (h, s, l, a = 1) => {
|
|
|
196
197
|
console.warn(`Alpha value must be between 0-1, ${a} converted to 1!`);
|
|
197
198
|
}
|
|
198
199
|
const rgb = (0, exports.convertHslToRgb)(h, s, l);
|
|
199
|
-
const rgbNumbers = (0,
|
|
200
|
+
const rgbNumbers = (0, utils_1.extractSolidColorValues)(rgb);
|
|
200
201
|
return (0, exports.convertRgbToRgba)(rgbNumbers[0], rgbNumbers[1], rgbNumbers[2], parseFloat(newAlpha.toFixed(1)));
|
|
201
202
|
};
|
|
202
203
|
exports.convertHslaToRgba = convertHslaToRgba;
|
|
@@ -216,7 +217,7 @@ const convertRgbaToHsla = (r, g, b, a = 1) => {
|
|
|
216
217
|
console.warn(`Alpha value must be between 0-1, ${a} converted to 1!`);
|
|
217
218
|
}
|
|
218
219
|
const hsl = (0, exports.convertRgbToHsl)(r, g, b);
|
|
219
|
-
const hslNumbers = (0,
|
|
220
|
+
const hslNumbers = (0, utils_1.extractSolidColorValues)(hsl);
|
|
220
221
|
return `hsla(${hslNumbers[0]}, ${hslNumbers[1]}%, ${hslNumbers[2]}%, ${parseFloat(newAlpha.toFixed(1))})`;
|
|
221
222
|
};
|
|
222
223
|
exports.convertRgbaToHsla = convertRgbaToHsla;
|
|
@@ -267,7 +268,7 @@ exports.convertHslaToHex8 = convertHslaToHex8;
|
|
|
267
268
|
*/
|
|
268
269
|
const convertHex8ToHsla = (hex8) => {
|
|
269
270
|
const rgba = (0, exports.convertHex8ToRgba)(hex8);
|
|
270
|
-
return (0, exports.convertRgbaToHsla)(...(0,
|
|
271
|
+
return (0, exports.convertRgbaToHsla)(...(0, utils_1.extractAlphaColorValues)(rgba));
|
|
271
272
|
};
|
|
272
273
|
exports.convertHex8ToHsla = convertHex8ToHsla;
|
|
273
274
|
/**
|
|
@@ -285,14 +286,14 @@ function convertColorCode(color) {
|
|
|
285
286
|
};
|
|
286
287
|
}
|
|
287
288
|
if ((0, helpers_1._isRGB)(color)) {
|
|
288
|
-
const rgbValues = (0,
|
|
289
|
+
const rgbValues = (0, utils_1.extractSolidColorValues)(color);
|
|
289
290
|
return {
|
|
290
291
|
hex: (0, exports.convertRgbToHex)(...rgbValues),
|
|
291
292
|
hsl: (0, exports.convertRgbToHsl)(...rgbValues),
|
|
292
293
|
};
|
|
293
294
|
}
|
|
294
295
|
if ((0, helpers_1._isHSL)(color)) {
|
|
295
|
-
const hslValues = (0,
|
|
296
|
+
const hslValues = (0, utils_1.extractSolidColorValues)(color);
|
|
296
297
|
return {
|
|
297
298
|
hex: (0, exports.convertHslToHex)(...hslValues),
|
|
298
299
|
rgb: (0, exports.convertHslToRgb)(...hslValues),
|
|
@@ -305,14 +306,14 @@ function convertColorCode(color) {
|
|
|
305
306
|
};
|
|
306
307
|
}
|
|
307
308
|
if ((0, helpers_1._isRGBA)(color)) {
|
|
308
|
-
const rgbaValues = (0,
|
|
309
|
+
const rgbaValues = (0, utils_1.extractAlphaColorValues)(color);
|
|
309
310
|
return {
|
|
310
311
|
hex8: (0, exports.convertRgbaToHex8)(...rgbaValues),
|
|
311
312
|
hsla: (0, exports.convertRgbaToHsla)(...rgbaValues),
|
|
312
313
|
};
|
|
313
314
|
}
|
|
314
315
|
if ((0, helpers_1._isHSLA)(color)) {
|
|
315
|
-
const hslaValues = (0,
|
|
316
|
+
const hslaValues = (0, utils_1.extractAlphaColorValues)(color);
|
|
316
317
|
return {
|
|
317
318
|
hex8: (0, exports.convertHslaToHex8)(...hslaValues),
|
|
318
319
|
rgba: (0, exports.convertHslaToRgba)(...hslaValues),
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.
|
|
3
|
+
exports._isSimilarToLast = exports._generateRandomHSL = exports._applyOpacity = exports._convertOpacityToHex = void 0;
|
|
4
4
|
exports._isHex6 = _isHex6;
|
|
5
5
|
exports._isHex8 = _isHex8;
|
|
6
6
|
exports._isRGB = _isRGB;
|
|
@@ -77,28 +77,6 @@ const _isSimilarToLast = (recentColors, newColor) => {
|
|
|
77
77
|
lightnessDifference < 16);
|
|
78
78
|
};
|
|
79
79
|
exports._isSimilarToLast = _isSimilarToLast;
|
|
80
|
-
/**
|
|
81
|
-
* * Extracts numbers from a color string like `rgb(66, 103, 69)` or `hsl(120, 42.86%, 41.18%)`.
|
|
82
|
-
* * Converts percentage values to decimal (e.g., `42.86%` → `42.86`).
|
|
83
|
-
*
|
|
84
|
-
* @param colorString The color string in RGB or HSL format.
|
|
85
|
-
* @returns An array of extracted numbers.
|
|
86
|
-
*/
|
|
87
|
-
const _extractSolidColorValues = (colorString) => {
|
|
88
|
-
return (colorString.match(/[\d.]+%?/g) || []).map((value) => parseFloat(value));
|
|
89
|
-
};
|
|
90
|
-
exports._extractSolidColorValues = _extractSolidColorValues;
|
|
91
|
-
/**
|
|
92
|
-
* * Extracts numbers from a color string like `rgba(66, 103, 69, 0.6)` or `hsla(120, 42.86%, 41.18%, 0.9)`.
|
|
93
|
-
* * Converts percentage values to decimal (e.g., `42.86%` → `42.86`).
|
|
94
|
-
*
|
|
95
|
-
* @param colorString The color string in RGB or HSL format.
|
|
96
|
-
* @returns An array of extracted numbers.
|
|
97
|
-
*/
|
|
98
|
-
const _extractAlphaColorValues = (colorString) => {
|
|
99
|
-
return (colorString.match(/[\d.]+%?/g) || []).map((value) => parseFloat(value));
|
|
100
|
-
};
|
|
101
|
-
exports._extractAlphaColorValues = _extractAlphaColorValues;
|
|
102
80
|
/**
|
|
103
81
|
* @private Checks if a color is in `Hex` format.
|
|
104
82
|
*
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.extractAlphaColorValues = exports.extractSolidColorValues = void 0;
|
|
4
|
+
const helpers_1 = require("./helpers");
|
|
5
|
+
/**
|
|
6
|
+
* * Extracts numbers from a color string like `rgb(66, 103, 69)` or `hsl(120, 42.86%, 41.18%)`.
|
|
7
|
+
* * Converts percentage values to decimal (e.g., `42.86%` → `42.86`).
|
|
8
|
+
*
|
|
9
|
+
* @param color The color string in RGB or HSL format.
|
|
10
|
+
* @returns A tuple of 3 extracted numbers. `[number, number, number]`
|
|
11
|
+
*
|
|
12
|
+
* @remarks If the input color is not in `HSL` or `RGB` format, it will return `[0, 0, 0]`
|
|
13
|
+
*/
|
|
14
|
+
const extractSolidColorValues = (color) => {
|
|
15
|
+
if (!(0, helpers_1._isHSL)(color) ||
|
|
16
|
+
!(0, helpers_1._isRGB)(color) ||
|
|
17
|
+
!(0, helpers_1._isHSLA)(color) ||
|
|
18
|
+
!(0, helpers_1._isRGBA)(color)) {
|
|
19
|
+
return (color.match(/[\d.]+%?/g) || []).map((value) => parseFloat(value));
|
|
20
|
+
}
|
|
21
|
+
return [0, 0, 0];
|
|
22
|
+
};
|
|
23
|
+
exports.extractSolidColorValues = extractSolidColorValues;
|
|
24
|
+
/**
|
|
25
|
+
* * Extracts numbers from a color string like `rgba(66, 103, 69, 0.6)` or `hsla(120, 42.86%, 41.18%, 0.9)`.
|
|
26
|
+
* * Converts percentage values to decimal (e.g., `42.86%` → `42.86`).
|
|
27
|
+
*
|
|
28
|
+
* @param color The color string in RGBA or HSLA format.
|
|
29
|
+
* @returns A tuple of 4 extracted numbers. `[number, number, number, number]`
|
|
30
|
+
*
|
|
31
|
+
* @remarks If the input color is not in `HSLA` or `RGBA` format, it will return `[0, 0, 0, 0]`
|
|
32
|
+
*/
|
|
33
|
+
const extractAlphaColorValues = (color) => {
|
|
34
|
+
if ((0, helpers_1._isHSL)(color) || (0, helpers_1._isRGB)(color) || (0, helpers_1._isHSLA)(color) || (0, helpers_1._isRGBA)(color)) {
|
|
35
|
+
return (color.match(/[\d.]+%?/g) || []).map((value) => parseFloat(value));
|
|
36
|
+
}
|
|
37
|
+
return [0, 0, 0, 0];
|
|
38
|
+
};
|
|
39
|
+
exports.extractAlphaColorValues = extractAlphaColorValues;
|
package/dist/cjs/date/utils.js
CHANGED
|
@@ -37,19 +37,6 @@ function getTotalMinutes(time) {
|
|
|
37
37
|
function getCurrentDateTime() {
|
|
38
38
|
return new Date();
|
|
39
39
|
}
|
|
40
|
-
// /**
|
|
41
|
-
// * * Converts a date into a Chronos object.
|
|
42
|
-
// *
|
|
43
|
-
// * @param date - A date value. It can be a `string`, `number`, `Date`, or `Chronos` object.
|
|
44
|
-
// * - If a string is provided, it should be in a format that can be parsed by the Date constructor.
|
|
45
|
-
// * - If a number is provided, it should be a timestamp (milliseconds since the Unix epoch).
|
|
46
|
-
// * - If a Date object is provided, it will be used as is.
|
|
47
|
-
// * - If a Chronos object is provided, it will be converted to a Date object.
|
|
48
|
-
// * @returns A new Chronos object representing the provided date.
|
|
49
|
-
// */
|
|
50
|
-
// export function chronos(date?: ChronosInput) {
|
|
51
|
-
// return new Chronos(date);
|
|
52
|
-
// }
|
|
53
40
|
/**
|
|
54
41
|
* * Extract Time in `HH:MM` format from given UTC value.
|
|
55
42
|
*
|
|
@@ -75,8 +62,9 @@ function extractMinutesFromUTC(utc) {
|
|
|
75
62
|
* @returns A formatted UTC offset string like `UTC+05:30` or `UTC-04:00`.
|
|
76
63
|
*/
|
|
77
64
|
function formatUTCOffset(minutes) {
|
|
78
|
-
const
|
|
79
|
-
const
|
|
65
|
+
const numMIn = typeof minutes === 'number' ? minutes : Number(minutes);
|
|
66
|
+
const sign = numMIn < 0 ? '-' : '+';
|
|
67
|
+
const abs = Math.abs(numMIn);
|
|
80
68
|
const hours = String(Math.floor(abs / 60)).padStart(2, '0');
|
|
81
69
|
const mins = String(abs % 60).padStart(2, '0');
|
|
82
70
|
return `UTC${sign}${hours}:${mins}`;
|
package/dist/cjs/index.js
CHANGED
|
@@ -16,11 +16,12 @@
|
|
|
16
16
|
*/
|
|
17
17
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
18
18
|
exports.calculatePercentage = exports.UnitConverter = exports.Unit = exports.Currency = exports.sumOfNumbers = exports.sumNumbers = exports.sumDigits = exports.reverseNumber = exports.getSumOfNumbers = exports.getRandomNumber = exports.getRandomInt = exports.getAverageOfNumbers = exports.getAverage = exports.convertToFixed = exports.convertToDecimal = exports.calculateLCM = exports.calculateLCD = exports.calculateHCF = exports.calculateGCD = exports.calculateAverage = exports.wordCount = exports.parseNumbersFromText = exports.levenshteinDistance = exports.getLevenshteinDistance = exports.extractNumbersFromString = exports.extractNumbers = exports.countWordsInString = exports.countWords = exports.slugifyString = exports.reverseString = exports.replaceAllInString = exports.normalizeString = exports.maskString = exports.formatWithPlural = exports.formatUnitWithPlural = exports.formatNumberWithPluralUnit = exports.extractURLs = exports.extractEmails = exports.convertStringCase = exports.isSnakeCase = exports.isPascalCase = exports.isPalindrome = exports.isKebabCase = exports.isEmojiOnly = exports.isCamelCase = exports.generateAnagrams = exports.truncateString = exports.trimString = exports.generateRandomID = exports.capitalizeString = void 0;
|
|
19
|
-
exports.
|
|
20
|
-
exports.
|
|
21
|
-
exports.
|
|
22
|
-
exports.
|
|
23
|
-
exports.
|
|
19
|
+
exports.getNumbersInRange = exports.roundToNearestInterval = exports.roundToNearest = exports.roundNumberToNearestInterval = exports.roundNumber = exports.numberToOrdinal = exports.getRandomFloat = exports.getRandomDecimal = exports.getOrdinalNumber = exports.getOrdinal = exports.formatCurrency = exports.convertToOrdinal = exports.convertNumberToOrdinal = exports.convertNumberToCurrency = exports.clampNumber = exports.cardinalToOrdinal = exports.isPrimeNumber = exports.isPrime = exports.getPrimeNumbers = exports.findPrimeNumbers = exports.toRomanNumeral = exports.toRoman = exports.numericToRoman = exports.numberToWords = exports.numberToRoman = exports.integerToRoman = exports.convertToRomanNumerals = exports.convertNumberToWords = exports.isPerfectSquare = exports.isParOfFibonacciSeries = exports.isParOfFibonacci = exports.isOddNumber = exports.isOdd = exports.isNumberInvalid = exports.isMultiple = exports.isInvalidNumber = exports.isFibonacci = exports.isEvenNumber = exports.isEven = exports.areNumbersInvalid = exports.areInvalidNumbers = exports.getNthFibonacci = exports.getMemoizedFibonacciSeries = exports.getMemoizedFibonacci = exports.getFibonacciSeriesMemo = exports.getFibonacciSeries = exports.getFibonacciNumbers = exports.getFibonacci = exports.generateFibonacci = exports.fibonacciGenerator = void 0;
|
|
20
|
+
exports.getTotalMinutesFromTime = exports.getTotalMinutes = exports.getTimeStringFromUTC = exports.getMinutesFromUTC = exports.getCurrentTime = exports.getCurrentDateTime = exports.formatUTCOffset = exports.extractTotalMinutesFromTime = exports.extractTimeStringFromUTC = exports.extractTimeFromUTC = exports.extractMinutesFromUTC = exports.extractHourMinute = exports.convertMinutesToUTCOffset = exports.chronusts = exports.chronusjs = exports.chronus = exports.chronosts = exports.chronosjs = exports.chronos = exports.Chronus = exports.Chronos = exports.isValidUTCOffSet = exports.isValidUTC = exports.isValidTimeString = exports.isValidTime = exports.isLeapYear = exports.greet = exports.getGreeting = exports.generateGreeting = exports.extractSolidColorValues = exports.extractAlphaColorValues = exports.Colour = exports.Color = exports.convertRgbToRgba = exports.convertRgbToHsl = exports.convertRgbToHex = exports.convertRgbaToHsla = exports.convertRgbaToHex8 = exports.convertHslToRgb = exports.convertHslToHex = exports.convertHslaToRgba = exports.convertHslaToHex8 = exports.convertHexToRgb = exports.convertHexToHsl = exports.convertHex8ToRgba = exports.convertHex8ToHsla = exports.convertColorCode = exports.generateRandomHSLColor = exports.generateRandomColorInHexRGB = exports.getColorForInitial = void 0;
|
|
21
|
+
exports.parseObjectValues = exports.parseJsonToObject = exports.mergeObjects = exports.mergeAndFlattenObjects = exports.flattenObjectKeyValue = exports.flattenObjectDotNotation = exports.extractUpdatedFields = exports.extractUpdatedAndNewFields = exports.extractNewFields = exports.countObjectFields = exports.cloneObject = exports.isValidFormData = exports.isOriginFileObj = exports.isFileUpload = exports.isFileList = exports.isFileArray = exports.isCustomFileArray = exports.isCustomFile = exports.serializeForm = exports.parseFormData = exports.createFormData = exports.createControlledFormData = exports.convertIntoFormData = exports.naturalSortForString = exports.naturalSort = exports.compareSorter = exports.compareNaturally = exports.splitArray = exports.rotateArray = exports.removeDuplicatesFromArray = exports.removeDuplicates = exports.moveArrayElement = exports.getMissingElements = exports.getDuplicatesFromArray = exports.getDuplicates = exports.findMissingElements = exports.extractMissingElements = exports.extractDuplicatesFromArray = exports.extractDuplicates = exports.createOptionsArray = exports.sortAnArray = exports.Finder = exports.shuffleArray = exports.isValidEmptyArray = exports.isInvalidOrEmptyArray = exports.getLastArrayElement = exports.flattenArray = exports.filterArrayOfObjects = exports.minutesToUTCOffset = exports.getTotalMinutesFromUTC = void 0;
|
|
22
|
+
exports.isNonEmptyString = exports.isInteger = exports.isFalsy = exports.isBoolean = exports.Paginator = exports.throttleAction = exports.parsePrimitivesDeep = exports.parseJsonDeep = exports.parseJSON = exports.isDeepEqual = exports.getStaticMethodsCount = exports.getStaticMethodNames = exports.getInstanceMethodsCount = exports.getInstanceMethodNames = exports.getClassDetails = exports.deepParsePrimitives = exports.debounceAction = exports.countStaticMethods = exports.countInstanceMethods = exports.convertArrayToString = exports.saveToSessionStorage = exports.saveToLocalStorage = exports.removeFromSessionStorage = exports.removeFromLocalStorage = exports.getFromSessionStorage = exports.getFromLocalStorage = exports.toggleFullScreen = exports.smoothScrollTo = exports.copyToClipboard = exports.updateQueryParam = exports.queryStringToObject = exports.parseQueryString = exports.getQueryStringAsObject = exports.getQueryParams = exports.generateQueryParams = exports.formatQueryParams = exports.createQueryParams = exports.remapObjectFields = exports.remapFields = exports.pickObjectFieldsByCondition = exports.pickObjectFields = exports.pickFieldsByCondition = exports.pickFields = exports.convertObjectValues = exports.sanitizeData = exports.parseStringifiedValues = exports.parseStringifiedPrimitives = exports.parseStringifiedObjectValues = exports.parsePrimitives = exports.parsePrimitiveData = void 0;
|
|
23
|
+
exports.isPhoneNumber = exports.isNumericString = exports.isNodeEnvironment = exports.isNodeENV = exports.isNode = exports.isIPAddress = exports.isExpectedNodeENV = exports.isEnvironment = exports.isEmailArray = exports.isEmail = exports.isDateString = exports.isBrowser = exports.isBase64 = exports.isValidSet = exports.isValidObject = exports.isValidMap = exports.isValidJSON = exports.isValidArray = exports.isSet = exports.isReturningPromise = exports.isRegularExpression = exports.isRegExp = exports.isPromise = exports.isObjectWithKeys = exports.isObjectEmpty = exports.isObject = exports.isNotEmptyObject = exports.isMethodDescriptor = exports.isMethod = exports.isMap = exports.isJSONObject = exports.isJSON = exports.isFunction = exports.isError = exports.isEmptyObjectGuard = exports.isEmptyObject = exports.isDate = exports.isBigInt = exports.isArrayWithLength = exports.isArrayOfType = exports.isArray = exports.doesReturnPromise = exports.isUndefined = exports.isTruthy = exports.isSymbol = exports.isString = exports.isPrimitive = exports.isPositiveInteger = exports.isNumber = exports.isNull = void 0;
|
|
24
|
+
exports.isValidURL = exports.isValidEmail = exports.isUUID = exports.isURL = void 0;
|
|
24
25
|
// ! String Utilities
|
|
25
26
|
var basics_1 = require("./string/basics");
|
|
26
27
|
Object.defineProperty(exports, "capitalizeString", { enumerable: true, get: function () { return basics_1.capitalizeString; } });
|
|
@@ -94,11 +95,13 @@ Object.defineProperty(exports, "getMemoizedFibonacciSeries", { enumerable: true,
|
|
|
94
95
|
Object.defineProperty(exports, "getNthFibonacci", { enumerable: true, get: function () { return fibonacci_1.getNthFibonacci; } });
|
|
95
96
|
var guards_2 = require("./number/guards");
|
|
96
97
|
Object.defineProperty(exports, "areInvalidNumbers", { enumerable: true, get: function () { return guards_2.areInvalidNumbers; } });
|
|
98
|
+
Object.defineProperty(exports, "areNumbersInvalid", { enumerable: true, get: function () { return guards_2.areInvalidNumbers; } });
|
|
97
99
|
Object.defineProperty(exports, "isEven", { enumerable: true, get: function () { return guards_2.isEven; } });
|
|
98
100
|
Object.defineProperty(exports, "isEvenNumber", { enumerable: true, get: function () { return guards_2.isEven; } });
|
|
99
101
|
Object.defineProperty(exports, "isFibonacci", { enumerable: true, get: function () { return guards_2.isFibonacci; } });
|
|
100
|
-
Object.defineProperty(exports, "
|
|
102
|
+
Object.defineProperty(exports, "isInvalidNumber", { enumerable: true, get: function () { return guards_2.areInvalidNumbers; } });
|
|
101
103
|
Object.defineProperty(exports, "isMultiple", { enumerable: true, get: function () { return guards_2.isMultiple; } });
|
|
104
|
+
Object.defineProperty(exports, "isNumberInvalid", { enumerable: true, get: function () { return guards_2.areInvalidNumbers; } });
|
|
102
105
|
Object.defineProperty(exports, "isOdd", { enumerable: true, get: function () { return guards_2.isOdd; } });
|
|
103
106
|
Object.defineProperty(exports, "isOddNumber", { enumerable: true, get: function () { return guards_2.isOdd; } });
|
|
104
107
|
Object.defineProperty(exports, "isParOfFibonacci", { enumerable: true, get: function () { return guards_2.isFibonacci; } });
|
|
@@ -107,11 +110,11 @@ Object.defineProperty(exports, "isPerfectSquare", { enumerable: true, get: funct
|
|
|
107
110
|
var convert_2 = require("./number/convert");
|
|
108
111
|
Object.defineProperty(exports, "convertNumberToWords", { enumerable: true, get: function () { return convert_2.numberToWords; } });
|
|
109
112
|
Object.defineProperty(exports, "convertToRomanNumerals", { enumerable: true, get: function () { return convert_2.convertToRomanNumerals; } });
|
|
113
|
+
Object.defineProperty(exports, "integerToRoman", { enumerable: true, get: function () { return convert_2.convertToRomanNumerals; } });
|
|
114
|
+
Object.defineProperty(exports, "numberToRoman", { enumerable: true, get: function () { return convert_2.convertToRomanNumerals; } });
|
|
110
115
|
Object.defineProperty(exports, "numberToWords", { enumerable: true, get: function () { return convert_2.numberToWords; } });
|
|
111
116
|
Object.defineProperty(exports, "numericToRoman", { enumerable: true, get: function () { return convert_2.convertToRomanNumerals; } });
|
|
112
117
|
Object.defineProperty(exports, "toRoman", { enumerable: true, get: function () { return convert_2.convertToRomanNumerals; } });
|
|
113
|
-
Object.defineProperty(exports, "numberToRoman", { enumerable: true, get: function () { return convert_2.convertToRomanNumerals; } });
|
|
114
|
-
Object.defineProperty(exports, "integerToRoman", { enumerable: true, get: function () { return convert_2.convertToRomanNumerals; } });
|
|
115
118
|
Object.defineProperty(exports, "toRomanNumeral", { enumerable: true, get: function () { return convert_2.convertToRomanNumerals; } });
|
|
116
119
|
var prime_1 = require("./number/prime");
|
|
117
120
|
Object.defineProperty(exports, "findPrimeNumbers", { enumerable: true, get: function () { return prime_1.findPrimeNumbers; } });
|
|
@@ -160,6 +163,9 @@ Object.defineProperty(exports, "convertRgbToRgba", { enumerable: true, get: func
|
|
|
160
163
|
var Color_1 = require("./colors/Color");
|
|
161
164
|
Object.defineProperty(exports, "Color", { enumerable: true, get: function () { return Color_1.Color; } });
|
|
162
165
|
Object.defineProperty(exports, "Colour", { enumerable: true, get: function () { return Color_1.Color; } });
|
|
166
|
+
var utils_1 = require("./colors/utils");
|
|
167
|
+
Object.defineProperty(exports, "extractAlphaColorValues", { enumerable: true, get: function () { return utils_1.extractAlphaColorValues; } });
|
|
168
|
+
Object.defineProperty(exports, "extractSolidColorValues", { enumerable: true, get: function () { return utils_1.extractSolidColorValues; } });
|
|
163
169
|
// ! Date & Time Utilities
|
|
164
170
|
var greet_1 = require("./date/greet");
|
|
165
171
|
Object.defineProperty(exports, "generateGreeting", { enumerable: true, get: function () { return greet_1.getGreeting; } });
|
|
@@ -181,22 +187,22 @@ Object.defineProperty(exports, "chronosts", { enumerable: true, get: function ()
|
|
|
181
187
|
Object.defineProperty(exports, "chronus", { enumerable: true, get: function () { return chronos_fn_1.chronos; } });
|
|
182
188
|
Object.defineProperty(exports, "chronusjs", { enumerable: true, get: function () { return chronos_fn_1.chronos; } });
|
|
183
189
|
Object.defineProperty(exports, "chronusts", { enumerable: true, get: function () { return chronos_fn_1.chronos; } });
|
|
184
|
-
var
|
|
185
|
-
Object.defineProperty(exports, "convertMinutesToUTCOffset", { enumerable: true, get: function () { return
|
|
186
|
-
Object.defineProperty(exports, "extractHourMinute", { enumerable: true, get: function () { return
|
|
187
|
-
Object.defineProperty(exports, "extractMinutesFromUTC", { enumerable: true, get: function () { return
|
|
188
|
-
Object.defineProperty(exports, "extractTimeFromUTC", { enumerable: true, get: function () { return
|
|
189
|
-
Object.defineProperty(exports, "extractTimeStringFromUTC", { enumerable: true, get: function () { return
|
|
190
|
-
Object.defineProperty(exports, "extractTotalMinutesFromTime", { enumerable: true, get: function () { return
|
|
191
|
-
Object.defineProperty(exports, "formatUTCOffset", { enumerable: true, get: function () { return
|
|
192
|
-
Object.defineProperty(exports, "getCurrentDateTime", { enumerable: true, get: function () { return
|
|
193
|
-
Object.defineProperty(exports, "getCurrentTime", { enumerable: true, get: function () { return
|
|
194
|
-
Object.defineProperty(exports, "getMinutesFromUTC", { enumerable: true, get: function () { return
|
|
195
|
-
Object.defineProperty(exports, "getTimeStringFromUTC", { enumerable: true, get: function () { return
|
|
196
|
-
Object.defineProperty(exports, "getTotalMinutes", { enumerable: true, get: function () { return
|
|
197
|
-
Object.defineProperty(exports, "getTotalMinutesFromTime", { enumerable: true, get: function () { return
|
|
198
|
-
Object.defineProperty(exports, "getTotalMinutesFromUTC", { enumerable: true, get: function () { return
|
|
199
|
-
Object.defineProperty(exports, "minutesToUTCOffset", { enumerable: true, get: function () { return
|
|
190
|
+
var utils_2 = require("./date/utils");
|
|
191
|
+
Object.defineProperty(exports, "convertMinutesToUTCOffset", { enumerable: true, get: function () { return utils_2.formatUTCOffset; } });
|
|
192
|
+
Object.defineProperty(exports, "extractHourMinute", { enumerable: true, get: function () { return utils_2.extractHourMinute; } });
|
|
193
|
+
Object.defineProperty(exports, "extractMinutesFromUTC", { enumerable: true, get: function () { return utils_2.extractMinutesFromUTC; } });
|
|
194
|
+
Object.defineProperty(exports, "extractTimeFromUTC", { enumerable: true, get: function () { return utils_2.extractTimeFromUTC; } });
|
|
195
|
+
Object.defineProperty(exports, "extractTimeStringFromUTC", { enumerable: true, get: function () { return utils_2.extractTimeFromUTC; } });
|
|
196
|
+
Object.defineProperty(exports, "extractTotalMinutesFromTime", { enumerable: true, get: function () { return utils_2.getTotalMinutes; } });
|
|
197
|
+
Object.defineProperty(exports, "formatUTCOffset", { enumerable: true, get: function () { return utils_2.formatUTCOffset; } });
|
|
198
|
+
Object.defineProperty(exports, "getCurrentDateTime", { enumerable: true, get: function () { return utils_2.getCurrentDateTime; } });
|
|
199
|
+
Object.defineProperty(exports, "getCurrentTime", { enumerable: true, get: function () { return utils_2.getCurrentDateTime; } });
|
|
200
|
+
Object.defineProperty(exports, "getMinutesFromUTC", { enumerable: true, get: function () { return utils_2.extractMinutesFromUTC; } });
|
|
201
|
+
Object.defineProperty(exports, "getTimeStringFromUTC", { enumerable: true, get: function () { return utils_2.extractTimeFromUTC; } });
|
|
202
|
+
Object.defineProperty(exports, "getTotalMinutes", { enumerable: true, get: function () { return utils_2.getTotalMinutes; } });
|
|
203
|
+
Object.defineProperty(exports, "getTotalMinutesFromTime", { enumerable: true, get: function () { return utils_2.getTotalMinutes; } });
|
|
204
|
+
Object.defineProperty(exports, "getTotalMinutesFromUTC", { enumerable: true, get: function () { return utils_2.extractMinutesFromUTC; } });
|
|
205
|
+
Object.defineProperty(exports, "minutesToUTCOffset", { enumerable: true, get: function () { return utils_2.formatUTCOffset; } });
|
|
200
206
|
// ! Array Utilities
|
|
201
207
|
var basics_3 = require("./array/basics");
|
|
202
208
|
Object.defineProperty(exports, "filterArrayOfObjects", { enumerable: true, get: function () { return basics_3.filterArrayOfObjects; } });
|
|
@@ -223,11 +229,11 @@ Object.defineProperty(exports, "removeDuplicates", { enumerable: true, get: func
|
|
|
223
229
|
Object.defineProperty(exports, "removeDuplicatesFromArray", { enumerable: true, get: function () { return transform_1.removeDuplicatesFromArray; } });
|
|
224
230
|
Object.defineProperty(exports, "rotateArray", { enumerable: true, get: function () { return transform_1.rotateArray; } });
|
|
225
231
|
Object.defineProperty(exports, "splitArray", { enumerable: true, get: function () { return transform_1.splitArray; } });
|
|
226
|
-
var
|
|
227
|
-
Object.defineProperty(exports, "compareNaturally", { enumerable: true, get: function () { return
|
|
228
|
-
Object.defineProperty(exports, "compareSorter", { enumerable: true, get: function () { return
|
|
229
|
-
Object.defineProperty(exports, "naturalSort", { enumerable: true, get: function () { return
|
|
230
|
-
Object.defineProperty(exports, "naturalSortForString", { enumerable: true, get: function () { return
|
|
232
|
+
var utils_3 = require("./array/utils");
|
|
233
|
+
Object.defineProperty(exports, "compareNaturally", { enumerable: true, get: function () { return utils_3.naturalSort; } });
|
|
234
|
+
Object.defineProperty(exports, "compareSorter", { enumerable: true, get: function () { return utils_3.naturalSort; } });
|
|
235
|
+
Object.defineProperty(exports, "naturalSort", { enumerable: true, get: function () { return utils_3.naturalSort; } });
|
|
236
|
+
Object.defineProperty(exports, "naturalSortForString", { enumerable: true, get: function () { return utils_3.naturalSort; } });
|
|
231
237
|
// ! Form Utilities
|
|
232
238
|
var convert_4 = require("./form/convert");
|
|
233
239
|
Object.defineProperty(exports, "convertIntoFormData", { enumerable: true, get: function () { return convert_4.createControlledFormData; } });
|
|
@@ -283,10 +289,10 @@ Object.defineProperty(exports, "getQueryStringAsObject", { enumerable: true, get
|
|
|
283
289
|
Object.defineProperty(exports, "parseQueryString", { enumerable: true, get: function () { return query_1.parseQueryString; } });
|
|
284
290
|
Object.defineProperty(exports, "queryStringToObject", { enumerable: true, get: function () { return query_1.parseQueryString; } });
|
|
285
291
|
Object.defineProperty(exports, "updateQueryParam", { enumerable: true, get: function () { return query_1.updateQueryParam; } });
|
|
286
|
-
var
|
|
287
|
-
Object.defineProperty(exports, "copyToClipboard", { enumerable: true, get: function () { return
|
|
288
|
-
Object.defineProperty(exports, "smoothScrollTo", { enumerable: true, get: function () { return
|
|
289
|
-
Object.defineProperty(exports, "toggleFullScreen", { enumerable: true, get: function () { return
|
|
292
|
+
var utils_4 = require("./dom/utils");
|
|
293
|
+
Object.defineProperty(exports, "copyToClipboard", { enumerable: true, get: function () { return utils_4.copyToClipboard; } });
|
|
294
|
+
Object.defineProperty(exports, "smoothScrollTo", { enumerable: true, get: function () { return utils_4.smoothScrollTo; } });
|
|
295
|
+
Object.defineProperty(exports, "toggleFullScreen", { enumerable: true, get: function () { return utils_4.toggleFullScreen; } });
|
|
290
296
|
var storage_1 = require("./dom/storage");
|
|
291
297
|
Object.defineProperty(exports, "getFromLocalStorage", { enumerable: true, get: function () { return storage_1.getFromLocalStorage; } });
|
|
292
298
|
Object.defineProperty(exports, "getFromSessionStorage", { enumerable: true, get: function () { return storage_1.getFromSessionStorage; } });
|
|
@@ -295,22 +301,22 @@ Object.defineProperty(exports, "removeFromSessionStorage", { enumerable: true, g
|
|
|
295
301
|
Object.defineProperty(exports, "saveToLocalStorage", { enumerable: true, get: function () { return storage_1.saveToLocalStorage; } });
|
|
296
302
|
Object.defineProperty(exports, "saveToSessionStorage", { enumerable: true, get: function () { return storage_1.saveToSessionStorage; } });
|
|
297
303
|
// ! Other Utilities
|
|
298
|
-
var
|
|
299
|
-
Object.defineProperty(exports, "convertArrayToString", { enumerable: true, get: function () { return
|
|
300
|
-
Object.defineProperty(exports, "countInstanceMethods", { enumerable: true, get: function () { return
|
|
301
|
-
Object.defineProperty(exports, "countStaticMethods", { enumerable: true, get: function () { return
|
|
302
|
-
Object.defineProperty(exports, "debounceAction", { enumerable: true, get: function () { return
|
|
303
|
-
Object.defineProperty(exports, "deepParsePrimitives", { enumerable: true, get: function () { return
|
|
304
|
-
Object.defineProperty(exports, "getClassDetails", { enumerable: true, get: function () { return
|
|
305
|
-
Object.defineProperty(exports, "getInstanceMethodNames", { enumerable: true, get: function () { return
|
|
306
|
-
Object.defineProperty(exports, "getInstanceMethodsCount", { enumerable: true, get: function () { return
|
|
307
|
-
Object.defineProperty(exports, "getStaticMethodNames", { enumerable: true, get: function () { return
|
|
308
|
-
Object.defineProperty(exports, "getStaticMethodsCount", { enumerable: true, get: function () { return
|
|
309
|
-
Object.defineProperty(exports, "isDeepEqual", { enumerable: true, get: function () { return
|
|
310
|
-
Object.defineProperty(exports, "parseJSON", { enumerable: true, get: function () { return
|
|
311
|
-
Object.defineProperty(exports, "parseJsonDeep", { enumerable: true, get: function () { return
|
|
312
|
-
Object.defineProperty(exports, "parsePrimitivesDeep", { enumerable: true, get: function () { return
|
|
313
|
-
Object.defineProperty(exports, "throttleAction", { enumerable: true, get: function () { return
|
|
304
|
+
var utils_5 = require("./utils");
|
|
305
|
+
Object.defineProperty(exports, "convertArrayToString", { enumerable: true, get: function () { return utils_5.convertArrayToString; } });
|
|
306
|
+
Object.defineProperty(exports, "countInstanceMethods", { enumerable: true, get: function () { return utils_5.countInstanceMethods; } });
|
|
307
|
+
Object.defineProperty(exports, "countStaticMethods", { enumerable: true, get: function () { return utils_5.countStaticMethods; } });
|
|
308
|
+
Object.defineProperty(exports, "debounceAction", { enumerable: true, get: function () { return utils_5.debounceAction; } });
|
|
309
|
+
Object.defineProperty(exports, "deepParsePrimitives", { enumerable: true, get: function () { return utils_5.deepParsePrimitives; } });
|
|
310
|
+
Object.defineProperty(exports, "getClassDetails", { enumerable: true, get: function () { return utils_5.getClassDetails; } });
|
|
311
|
+
Object.defineProperty(exports, "getInstanceMethodNames", { enumerable: true, get: function () { return utils_5.getInstanceMethodNames; } });
|
|
312
|
+
Object.defineProperty(exports, "getInstanceMethodsCount", { enumerable: true, get: function () { return utils_5.countInstanceMethods; } });
|
|
313
|
+
Object.defineProperty(exports, "getStaticMethodNames", { enumerable: true, get: function () { return utils_5.getStaticMethodNames; } });
|
|
314
|
+
Object.defineProperty(exports, "getStaticMethodsCount", { enumerable: true, get: function () { return utils_5.countStaticMethods; } });
|
|
315
|
+
Object.defineProperty(exports, "isDeepEqual", { enumerable: true, get: function () { return utils_5.isDeepEqual; } });
|
|
316
|
+
Object.defineProperty(exports, "parseJSON", { enumerable: true, get: function () { return utils_5.parseJSON; } });
|
|
317
|
+
Object.defineProperty(exports, "parseJsonDeep", { enumerable: true, get: function () { return utils_5.parseJSON; } });
|
|
318
|
+
Object.defineProperty(exports, "parsePrimitivesDeep", { enumerable: true, get: function () { return utils_5.deepParsePrimitives; } });
|
|
319
|
+
Object.defineProperty(exports, "throttleAction", { enumerable: true, get: function () { return utils_5.throttleAction; } });
|
|
314
320
|
var Paginator_1 = require("./utils/Paginator");
|
|
315
321
|
Object.defineProperty(exports, "Paginator", { enumerable: true, get: function () { return Paginator_1.Paginator; } });
|
|
316
322
|
// ! Primitive Type Guards
|
|
@@ -11,9 +11,10 @@ const basics_1 = require("../string/basics");
|
|
|
11
11
|
*
|
|
12
12
|
* @param input - The string, object or array of strings or objects to sanitize.
|
|
13
13
|
* @param options - Options for processing.
|
|
14
|
+
* @param _return - By default return type is as it is, passing this parameter `partial` makes the return type `Partial<T>`.
|
|
14
15
|
* @returns A new string, object or array of strings or objects with the specified modifications.
|
|
15
16
|
*/
|
|
16
|
-
function sanitizeData(input, options) {
|
|
17
|
+
function sanitizeData(input, options, _return) {
|
|
17
18
|
const { keysToIgnore = [], requiredKeys = [], trimStrings = true, ignoreNullish = false, ignoreFalsy = false, ignoreEmpty = false, } = options || {};
|
|
18
19
|
// Flatten the object keys and use the keys for comparison
|
|
19
20
|
const ignoreKeySet = new Set(keysToIgnore);
|
|
@@ -32,7 +33,7 @@ function sanitizeData(input, options) {
|
|
|
32
33
|
* @param obj Object value to check.
|
|
33
34
|
* @returns `true` if the object is skippable, otherwise `false`.
|
|
34
35
|
*/
|
|
35
|
-
const
|
|
36
|
+
const _skipObject = (obj) => {
|
|
36
37
|
return ignoreEmpty && (0, non_primitives_1.isObject)(obj) && !(0, non_primitives_1.isNotEmptyObject)(obj);
|
|
37
38
|
};
|
|
38
39
|
/**
|
|
@@ -61,7 +62,7 @@ function sanitizeData(input, options) {
|
|
|
61
62
|
return false;
|
|
62
63
|
if (ignoreFalsy && !v)
|
|
63
64
|
return false;
|
|
64
|
-
if (
|
|
65
|
+
if (_skipObject(v) && !isRequiredKey(path))
|
|
65
66
|
return false;
|
|
66
67
|
return true;
|
|
67
68
|
});
|
|
@@ -131,13 +132,13 @@ function sanitizeData(input, options) {
|
|
|
131
132
|
}
|
|
132
133
|
// * Handle arrays with nested strings/arrays/objects
|
|
133
134
|
return input
|
|
134
|
-
.map((item) => sanitizeData(item, options))
|
|
135
|
+
.map((item) => sanitizeData(item, options, _return))
|
|
135
136
|
.filter((val) => {
|
|
136
137
|
if (ignoreNullish && val == null)
|
|
137
138
|
return false;
|
|
138
139
|
if (ignoreFalsy && !val)
|
|
139
140
|
return false;
|
|
140
|
-
if (
|
|
141
|
+
if (_skipObject(val))
|
|
141
142
|
return false;
|
|
142
143
|
return true;
|
|
143
144
|
});
|
|
@@ -99,7 +99,7 @@ export declare class Color {
|
|
|
99
99
|
*/
|
|
100
100
|
constructor(color: CSSColor);
|
|
101
101
|
/** - Iterates over the color representations (Hex, RGB, HSL). */
|
|
102
|
-
[Symbol.iterator](): Generator<
|
|
102
|
+
[Symbol.iterator](): Generator<HSL | RGB | HSLA | RGBA | Hex6 | Hex8, void, unknown>;
|
|
103
103
|
/**
|
|
104
104
|
* @instance Applies or modifies the opacity of a color. Mutate the original instance.
|
|
105
105
|
* - For solid colors (Hex6/RGB/HSL): Adds an alpha channel with the specified opacity.
|
|
@@ -156,13 +156,13 @@ export declare class Color {
|
|
|
156
156
|
* - `weight = 0.5` → equal blend between the two.
|
|
157
157
|
* @returns A new `Color` instance representing the blended result, with proper alpha blending.
|
|
158
158
|
*/
|
|
159
|
-
blendWith(other: ColorType, weight?: number): Color;
|
|
159
|
+
blendWith(other: ColorType | CSSColor, weight?: number): Color;
|
|
160
160
|
/**
|
|
161
161
|
* @instance Calculates the contrast ratio between this color and another color (WCAG).
|
|
162
162
|
* @param other - The other color to compare against.
|
|
163
163
|
* @returns A number representing the contrast ratio (rounded to 2 decimal places).
|
|
164
164
|
*/
|
|
165
|
-
contrastRatio(other: ColorType): number;
|
|
165
|
+
contrastRatio(other: ColorType | CSSColor): number;
|
|
166
166
|
/**
|
|
167
167
|
* @instance Returns the complementary color by rotating the hue 180 degrees.
|
|
168
168
|
* @returns A new Color that is the complement of the current color.
|
|
@@ -191,7 +191,7 @@ export declare class Color {
|
|
|
191
191
|
* @param other - The other color to test contrast against.
|
|
192
192
|
* @returns 'Fail', 'AA', or 'AAA' based on `WCAG 2.1` contrast standards.
|
|
193
193
|
*/
|
|
194
|
-
getWCAGRating(other: ColorType): 'Fail' | 'AA' | 'AAA';
|
|
194
|
+
getWCAGRating(other: ColorType | CSSColor): 'Fail' | 'AA' | 'AAA';
|
|
195
195
|
/**
|
|
196
196
|
* @instance Determines if the color is light based on its perceived brightness.
|
|
197
197
|
* @returns `true` if light, `false` if dark.
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Color.d.ts","sourceRoot":"","sources":["../../../src/colors/Color.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"Color.d.ts","sourceRoot":"","sources":["../../../src/colors/Color.ts"],"names":[],"mappings":"AAUA,OAAO,KAAK,EAEX,SAAS,EAET,SAAS,EACT,QAAQ,EACR,IAAI,EACJ,IAAI,EACJ,GAAG,EACH,IAAI,EACJ,OAAO,EACP,GAAG,EACH,IAAI,EAEJ,MAAM,EACN,KAAK,EACL,MAAM,SAAS,CAAC;AAMjB;;;;;;;;;;;GAWG;AACH,qBAAa,KAAK;;IACV,GAAG,EAAE,IAAI,CAAC;IACV,IAAI,EAAE,IAAI,CAAC;IACX,GAAG,EAAE,GAAG,CAAC;IACT,IAAI,EAAE,IAAI,CAAC;IACX,GAAG,EAAE,GAAG,CAAC;IACT,IAAI,EAAE,IAAI,CAAC;IAElB;;;;;;;;;;;;;;;;;;;;;;OAsBG;;IAGH;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;OAoCG;gBACS,KAAK,EAAE,SAAS;IAE5B;;;;;;;;;;;;;;;OAeG;gBACS,KAAK,EAAE,QAAQ;IAmG3B,iEAAiE;IAChE,CAAC,MAAM,CAAC,QAAQ,CAAC;IASlB;;;;;;;;;;;;;;;;;OAiBG;IACH,YAAY,CAAC,OAAO,EAAE,OAAO,GAAG,KAAK;IAkBrC;;;;OAIG;IACH,aAAa,CAAC,OAAO,EAAE,OAAO,GAAG,KAAK;IAUtC;;;;OAIG;IACH,eAAe,CAAC,OAAO,EAAE,OAAO,GAAG,KAAK;IAUxC;;;;OAIG;IACH,aAAa,CAAC,OAAO,EAAE,OAAO,GAAG,KAAK;IAUtC;;;;;OAKG;IACH,eAAe,CAAC,OAAO,EAAE,OAAO,GAAG,KAAK;IAYxC;;;;;;;;;;;OAWG;IACH,SAAS,CAAC,KAAK,EAAE,SAAS,GAAG,QAAQ,EAAE,MAAM,SAAM,GAAG,KAAK;IAwB3D;;;;OAIG;IACH,aAAa,CAAC,KAAK,EAAE,SAAS,GAAG,QAAQ,GAAG,MAAM;IA0BlD;;;OAGG;IACH,qBAAqB,IAAI,KAAK;IAU9B;;;;OAIG;IACH,kBAAkB,IAAI,SAAS;IAa/B;;;;OAIG;IACH,cAAc,IAAI,KAAK;IAWvB;;;;OAIG;IACH,eAAe,IAAI,MAAM;IAczB;;;;OAIG;IACH,aAAa,CAAC,KAAK,EAAE,SAAS,GAAG,QAAQ,GAAG,MAAM,GAAG,IAAI,GAAG,KAAK;IAQjE;;;OAGG;IACH,YAAY,IAAI,OAAO;IAQvB;;;;;OAKG;IACH,MAAM,CAAC,MAAM,CAAC,KAAK,EAAE,MAAM,GAAG,KAAK,IAAI,IAAI;IAI3C;;;;;OAKG;IACH,MAAM,CAAC,MAAM,CAAC,KAAK,EAAE,MAAM,GAAG,KAAK,IAAI,IAAI;IAI3C;;;;;OAKG;IACH,MAAM,CAAC,KAAK,CAAC,KAAK,EAAE,MAAM,GAAG,KAAK,IAAI,GAAG;IAIzC;;;;;OAKG;IACH,MAAM,CAAC,MAAM,CAAC,KAAK,EAAE,MAAM,GAAG,KAAK,IAAI,IAAI;IAI3C;;;;;OAKG;IACH,MAAM,CAAC,KAAK,CAAC,KAAK,EAAE,MAAM,GAAG,KAAK,IAAI,GAAG;IAIzC;;;;;OAKG;IACH,MAAM,CAAC,MAAM,CAAC,KAAK,EAAE,MAAM,GAAG,KAAK,IAAI,IAAI;IAI3C;;;;;;;OAOG;IACH,MAAM,CAAC,UAAU,CAAC,KAAK,EAAE,MAAM,GAAG,KAAK,IAAI,QAAQ;CA0DnD"}
|