nhb-toolbox 2.8.0 → 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.
Files changed (41) hide show
  1. package/dist/array/basics.js +7 -15
  2. package/dist/array/sort.js +1 -4
  3. package/dist/array/transform.js +4 -9
  4. package/dist/array/types.js +1 -2
  5. package/dist/colors/Color.js +17 -21
  6. package/dist/colors/constants.js +2 -5
  7. package/dist/colors/convert.js +56 -73
  8. package/dist/colors/helpers.js +13 -29
  9. package/dist/colors/initials.js +13 -16
  10. package/dist/colors/random.js +7 -12
  11. package/dist/colors/types.js +1 -2
  12. package/dist/form/convert.js +4 -9
  13. package/dist/form/guards.js +4 -10
  14. package/dist/form/transform.js +9 -13
  15. package/dist/form/types.js +1 -2
  16. package/dist/guards/non-primitives.js +17 -34
  17. package/dist/guards/primitives.js +12 -26
  18. package/dist/guards/specials.js +23 -37
  19. package/dist/index.d.ts +4 -4
  20. package/dist/index.d.ts.map +1 -1
  21. package/dist/index.js +25 -147
  22. package/dist/number/basics.js +11 -21
  23. package/dist/number/constants.js +4 -7
  24. package/dist/number/convert.js +5 -8
  25. package/dist/number/helpers.js +11 -18
  26. package/dist/number/prime.js +3 -8
  27. package/dist/number/range.js +12 -15
  28. package/dist/number/types.js +1 -2
  29. package/dist/object/basics.js +8 -16
  30. package/dist/object/convert.js +1 -4
  31. package/dist/object/objectify.js +22 -32
  32. package/dist/object/sanitize.js +8 -11
  33. package/dist/object/types.js +1 -2
  34. package/dist/string/anagram.js +1 -4
  35. package/dist/string/basics.js +4 -11
  36. package/dist/string/constants.js +1 -4
  37. package/dist/string/convert.js +4 -9
  38. package/dist/string/types.js +1 -2
  39. package/dist/types/index.js +1 -2
  40. package/dist/utils/index.js +8 -15
  41. package/package.json +2 -1
@@ -1,8 +1,4 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.replaceAllInString = void 0;
4
- exports.convertStringCase = convertStringCase;
5
- const constants_1 = require("./constants");
1
+ import { LOWERCASE } from './constants';
6
2
  /**
7
3
  * Converts a string to a specified case format such as `camelCase`, `snake_case`, `kebab-case`, `PascalCase`, `Title Case`, `lowercase`, or `UPPERCASE`.
8
4
  *
@@ -27,7 +23,7 @@ const constants_1 = require("./constants");
27
23
  * convertStringCase('my example string', 'lowercase'); // returns 'my example string'
28
24
  * convertStringCase('my example string', 'UPPERCASE'); // returns 'MY EXAMPLE STRING'
29
25
  */
30
- function convertStringCase(string, format) {
26
+ export function convertStringCase(string, format) {
31
27
  if (!string || typeof string !== 'string')
32
28
  return '';
33
29
  const start = string.match(/^[^\d\w\s]+/)?.[0] || '';
@@ -39,7 +35,7 @@ function convertStringCase(string, format) {
39
35
  const startSymbol = part.match(/^[^\d\w\s]+/)?.[0] || ''; // Capture leading symbols
40
36
  const endSymbol = part.match(/[^\d\w\s]+$/)?.[0] || ''; // Capture trailing symbols
41
37
  const coreWord = part.replace(/^[^\d\w\s]+|[^\d\w\s]+$/g, ''); // Remove them for processing
42
- if (constants_1.LOWERCASE.includes(coreWord.toLowerCase())) {
38
+ if (LOWERCASE.includes(coreWord.toLowerCase())) {
43
39
  return startSymbol + coreWord.toLowerCase() + endSymbol;
44
40
  }
45
41
  return (startSymbol +
@@ -98,7 +94,7 @@ function convertStringCase(string, format) {
98
94
  * @param replace - The string to replace matches with.
99
95
  * @returns The modified/refined string with replacements applied.
100
96
  */
101
- const replaceAllInString = (input, find, replace) => {
97
+ export const replaceAllInString = (input, find, replace) => {
102
98
  if (!input)
103
99
  return '';
104
100
  const trimmedString = input?.trim();
@@ -109,4 +105,3 @@ const replaceAllInString = (input, find, replace) => {
109
105
  : new RegExp(find, find.flags.includes('g') ? find.flags : find.flags + 'g');
110
106
  return trimmedString?.replace(regex, replace);
111
107
  };
112
- exports.replaceAllInString = replaceAllInString;
@@ -1,2 +1 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
1
+ export {};
@@ -1,2 +1 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
1
+ export {};
@@ -1,7 +1,4 @@
1
- "use strict";
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) => (0, exports.isDeepEqual)(element, b[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) => (0, exports.isDeepEqual)(a[key], b[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 (!basics_1.isInvalidOrEmptyArray) {
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.0",
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
  },