nhb-toolbox 2.8.1 → 2.8.2
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/array/basics.js +7 -15
- package/dist/array/sort.js +1 -4
- package/dist/array/transform.js +4 -9
- package/dist/array/types.js +1 -2
- package/dist/colors/Color.js +17 -21
- package/dist/colors/constants.js +2 -5
- package/dist/colors/convert.js +56 -73
- package/dist/colors/helpers.js +13 -29
- package/dist/colors/initials.js +13 -16
- package/dist/colors/random.js +7 -12
- package/dist/colors/types.js +1 -2
- package/dist/form/convert.js +4 -9
- package/dist/form/guards.js +4 -10
- package/dist/form/transform.js +9 -13
- package/dist/form/types.js +1 -2
- package/dist/guards/non-primitives.js +17 -34
- package/dist/guards/primitives.js +12 -26
- package/dist/guards/specials.js +23 -37
- package/dist/index.js +25 -156
- package/dist/number/basics.js +11 -21
- package/dist/number/constants.js +4 -7
- package/dist/number/convert.js +5 -8
- package/dist/number/helpers.js +11 -18
- package/dist/number/prime.js +3 -8
- package/dist/number/range.js +12 -15
- package/dist/number/types.js +1 -2
- package/dist/object/basics.js +8 -16
- package/dist/object/convert.js +1 -4
- package/dist/object/objectify.js +22 -32
- package/dist/object/sanitize.js +8 -11
- package/dist/object/types.js +1 -2
- package/dist/string/anagram.js +1 -4
- package/dist/string/basics.js +4 -11
- package/dist/string/constants.js +1 -4
- package/dist/string/convert.js +4 -9
- package/dist/string/types.js +1 -2
- package/dist/types/index.js +1 -2
- package/dist/utils/index.js +8 -15
- package/package.json +2 -1
package/dist/utils/index.js
CHANGED
|
@@ -1,7 +1,4 @@
|
|
|
1
|
-
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.throttleAction = exports.debounceAction = exports.convertArrayToString = exports.isDeepEqual = void 0;
|
|
4
|
-
const basics_1 = require("../array/basics");
|
|
1
|
+
import { isInvalidOrEmptyArray } from '../array/basics';
|
|
5
2
|
/**
|
|
6
3
|
* * Deeply compare two values (arrays, objects, or primitive values).
|
|
7
4
|
*
|
|
@@ -9,7 +6,7 @@ const basics_1 = require("../array/basics");
|
|
|
9
6
|
* @param b Second value to compare.
|
|
10
7
|
* @returns Whether the values are deeply equal.
|
|
11
8
|
*/
|
|
12
|
-
const isDeepEqual = (a, b) => {
|
|
9
|
+
export const isDeepEqual = (a, b) => {
|
|
13
10
|
// If both values are strictly equal (handles primitive types and same references)
|
|
14
11
|
if (a === b)
|
|
15
12
|
return true;
|
|
@@ -23,7 +20,7 @@ const isDeepEqual = (a, b) => {
|
|
|
23
20
|
if (Array.isArray(a) && Array.isArray(b)) {
|
|
24
21
|
if (a.length !== b.length)
|
|
25
22
|
return false;
|
|
26
|
-
return a.every((element, index) =>
|
|
23
|
+
return a.every((element, index) => isDeepEqual(element, b[index]));
|
|
27
24
|
}
|
|
28
25
|
// Check for object equality
|
|
29
26
|
if (typeof a === 'object' && typeof b === 'object') {
|
|
@@ -31,11 +28,10 @@ const isDeepEqual = (a, b) => {
|
|
|
31
28
|
const bKeys = Object.keys(b);
|
|
32
29
|
if (aKeys.length !== bKeys.length)
|
|
33
30
|
return false;
|
|
34
|
-
return aKeys.every((key) =>
|
|
31
|
+
return aKeys.every((key) => isDeepEqual(a[key], b[key]));
|
|
35
32
|
}
|
|
36
33
|
return false;
|
|
37
34
|
};
|
|
38
|
-
exports.isDeepEqual = isDeepEqual;
|
|
39
35
|
/**
|
|
40
36
|
* * Utility to convert an array to string with custom separator.
|
|
41
37
|
*
|
|
@@ -43,13 +39,12 @@ exports.isDeepEqual = isDeepEqual;
|
|
|
43
39
|
* @param separator Separate each element of the array. Can be `,`, `-`, `|` etc. Default is `,`.
|
|
44
40
|
* @returns Converted array in string format with the separator.
|
|
45
41
|
*/
|
|
46
|
-
const convertArrayToString = (array, separator = ',') => {
|
|
47
|
-
if (!
|
|
42
|
+
export const convertArrayToString = (array, separator = ',') => {
|
|
43
|
+
if (!isInvalidOrEmptyArray) {
|
|
48
44
|
throw new Error('Please, provide a valid array!');
|
|
49
45
|
}
|
|
50
46
|
return array.join(separator);
|
|
51
47
|
};
|
|
52
|
-
exports.convertArrayToString = convertArrayToString;
|
|
53
48
|
/**
|
|
54
49
|
* * A generic debounce function that delays the execution of a callback.
|
|
55
50
|
*
|
|
@@ -64,7 +59,7 @@ exports.convertArrayToString = convertArrayToString;
|
|
|
64
59
|
*
|
|
65
60
|
* debouncedSearch('laptop'); // Executes after 300ms of inactivity.
|
|
66
61
|
*/
|
|
67
|
-
const debounceAction = (callback, delay = 300) => {
|
|
62
|
+
export const debounceAction = (callback, delay = 300) => {
|
|
68
63
|
let timeoutId = undefined;
|
|
69
64
|
return (...args) => {
|
|
70
65
|
// Clear the previous timeout
|
|
@@ -75,7 +70,6 @@ const debounceAction = (callback, delay = 300) => {
|
|
|
75
70
|
}, delay);
|
|
76
71
|
};
|
|
77
72
|
};
|
|
78
|
-
exports.debounceAction = debounceAction;
|
|
79
73
|
/**
|
|
80
74
|
* * A generic throttle function that ensures a callback is executed at most once per specified interval.
|
|
81
75
|
*
|
|
@@ -90,7 +84,7 @@ exports.debounceAction = debounceAction;
|
|
|
90
84
|
*
|
|
91
85
|
* window.addEventListener('resize', throttledResize);
|
|
92
86
|
*/
|
|
93
|
-
const throttleAction = (callback, delay = 150) => {
|
|
87
|
+
export const throttleAction = (callback, delay = 150) => {
|
|
94
88
|
let lastCall = 0;
|
|
95
89
|
return (...args) => {
|
|
96
90
|
const now = Date.now();
|
|
@@ -100,4 +94,3 @@ const throttleAction = (callback, delay = 150) => {
|
|
|
100
94
|
}
|
|
101
95
|
};
|
|
102
96
|
};
|
|
103
|
-
exports.throttleAction = throttleAction;
|
package/package.json
CHANGED
|
@@ -1,9 +1,10 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "nhb-toolbox",
|
|
3
|
-
"version": "2.8.
|
|
3
|
+
"version": "2.8.2",
|
|
4
4
|
"description": "A versatile collection of smart, efficient, and reusable utility functions for everyday development needs.",
|
|
5
5
|
"main": "dist/index.js",
|
|
6
6
|
"types": "dist/index.d.ts",
|
|
7
|
+
"sideEffects": false,
|
|
7
8
|
"publishConfig": {
|
|
8
9
|
"access": "public"
|
|
9
10
|
},
|