nhb-toolbox 2.2.9 → 2.3.3

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/index.d.ts CHANGED
@@ -1,7 +1,7 @@
1
1
  export { capitalizeString, generateRandomID, trimString, truncateString, } from './string/basics';
2
2
  export { generateAnagrams } from './string/anagram';
3
3
  export { convertStringCase, replaceAllInString } from './string/convert';
4
- export { calculateHCF as calculateGCD, calculateHCF, calculateLCM as calculateLCD, calculateLCM, convertToDecimal, getRandomNumber, } from './number/basics';
4
+ export { calculateHCF as calculateGCD, calculateHCF, calculateLCM as calculateLCD, calculateLCM, convertToDecimal, getRandomNumber, isEven, isMultiple, isOdd, } from './number/basics';
5
5
  export { numberToWords } from './number/convert';
6
6
  export { findPrimeNumbers, isPrime } from './number/prime';
7
7
  export { getNumbersInRange } from './number/range';
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EACN,gBAAgB,EAChB,gBAAgB,EAChB,UAAU,EACV,cAAc,GACd,MAAM,iBAAiB,CAAC;AAEzB,OAAO,EAAE,gBAAgB,EAAE,MAAM,kBAAkB,CAAC;AAEpD,OAAO,EAAE,iBAAiB,EAAE,kBAAkB,EAAE,MAAM,kBAAkB,CAAC;AAEzE,OAAO,EACN,YAAY,IAAI,YAAY,EAC5B,YAAY,EACZ,YAAY,IAAI,YAAY,EAC5B,YAAY,EACZ,gBAAgB,EAChB,eAAe,GACf,MAAM,iBAAiB,CAAC;AAEzB,OAAO,EAAE,aAAa,EAAE,MAAM,kBAAkB,CAAC;AAEjD,OAAO,EAAE,gBAAgB,EAAE,OAAO,EAAE,MAAM,gBAAgB,CAAC;AAE3D,OAAO,EAAE,iBAAiB,EAAE,MAAM,gBAAgB,CAAC;AAEnD,OAAO,EAAE,kBAAkB,EAAE,MAAM,mBAAmB,CAAC;AAEvD,OAAO,EACN,2BAA2B,EAC3B,s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EACb,QAAQ,GACR,MAAM,iBAAiB,CAAC;AAEzB,OAAO,EACN,gBAAgB,EAChB,0BAA0B,EAC1B,oBAAoB,EACpB,wBAAwB,EACxB,qBAAqB,EACrB,sBAAsB,EACtB,YAAY,GACZ,MAAM,oBAAoB,CAAC;AAE5B,OAAO,EAAE,YAAY,EAAE,MAAM,mBAAmB,CAAC;AAEjD,OAAO,EAAE,mBAAmB,EAAE,MAAM,kBAAkB,CAAC;AAGvD,OAAO,EACN,oBAAoB,EACpB,cAAc,EACd,WAAW,EACX,cAAc,GACd,MAAM,SAAS,CAAC"}
package/dist/index.js CHANGED
@@ -1,7 +1,8 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.isObject = exports.isEmptyObject = exports.generateQueryParams = exports.countObjectFields = exports.cloneObject = exports.createControlledFormData = exports.isEmptyFormData = exports.convertIntoFormData = exports.removeDuplicatesFromArray = exports.createOptionsArray = exports.sortAnArray = exports.shuffleArray = exports.isValidEmptyArray = exports.flattenArray = exports.filterArrayOfObjects = 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 = exports.getNumbersInRange = exports.isPrime = exports.findPrimeNumbers = exports.numberToWords = exports.getRandomNumber = exports.convertToDecimal = exports.calculateLCM = exports.calculateLCD = exports.calculateHCF = exports.calculateGCD = exports.replaceAllInString = exports.convertStringCase = exports.generateAnagrams = exports.truncateString = exports.trimString = exports.generateRandomID = exports.capitalizeString = void 0;
4
- exports.throttleAction = exports.isDeepEqual = exports.debounceAction = exports.convertArrayToString = exports.convertObjectValues = exports.sanitizeData = exports.mergeObjects = exports.mergeAndFlattenObjects = exports.flattenObjectKeyValue = exports.flattenObjectDotNotation = exports.extractUpdatedFields = exports.extractUpdatedAndNewFields = exports.extractNewFields = void 0;
3
+ exports.countObjectFields = exports.cloneObject = exports.createControlledFormData = exports.isEmptyFormData = exports.convertIntoFormData = exports.removeDuplicatesFromArray = exports.createOptionsArray = exports.sortAnArray = exports.shuffleArray = exports.isValidEmptyArray = exports.flattenArray = exports.filterArrayOfObjects = 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 = exports.getNumbersInRange = exports.isPrime = exports.findPrimeNumbers = exports.numberToWords = exports.isOdd = exports.isMultiple = exports.isEven = exports.getRandomNumber = exports.convertToDecimal = exports.calculateLCM = exports.calculateLCD = exports.calculateHCF = exports.calculateGCD = exports.replaceAllInString = exports.convertStringCase = exports.generateAnagrams = exports.truncateString = exports.trimString = exports.generateRandomID = exports.capitalizeString = void 0;
4
+ exports.throttleAction = exports.isDeepEqual = exports.debounceAction = exports.convertArrayToString = exports.convertObjectValues = exports.sanitizeData = exports.mergeObjects = exports.mergeAndFlattenObjects = exports.flattenObjectKeyValue = exports.flattenObjectDotNotation = exports.extractUpdatedFields = exports.extractUpdatedAndNewFields = exports.extractNewFields = exports.isObject = exports.isEmptyObject = exports.generateQueryParams = void 0;
5
+ // ! String Utilities
5
6
  var basics_1 = require("./string/basics");
6
7
  Object.defineProperty(exports, "capitalizeString", { enumerable: true, get: function () { return basics_1.capitalizeString; } });
7
8
  Object.defineProperty(exports, "generateRandomID", { enumerable: true, get: function () { return basics_1.generateRandomID; } });
@@ -12,6 +13,7 @@ Object.defineProperty(exports, "generateAnagrams", { enumerable: true, get: func
12
13
  var convert_1 = require("./string/convert");
13
14
  Object.defineProperty(exports, "convertStringCase", { enumerable: true, get: function () { return convert_1.convertStringCase; } });
14
15
  Object.defineProperty(exports, "replaceAllInString", { enumerable: true, get: function () { return convert_1.replaceAllInString; } });
16
+ // ! Number Utilities
15
17
  var basics_2 = require("./number/basics");
16
18
  Object.defineProperty(exports, "calculateGCD", { enumerable: true, get: function () { return basics_2.calculateHCF; } });
17
19
  Object.defineProperty(exports, "calculateHCF", { enumerable: true, get: function () { return basics_2.calculateHCF; } });
@@ -19,6 +21,9 @@ Object.defineProperty(exports, "calculateLCD", { enumerable: true, get: function
19
21
  Object.defineProperty(exports, "calculateLCM", { enumerable: true, get: function () { return basics_2.calculateLCM; } });
20
22
  Object.defineProperty(exports, "convertToDecimal", { enumerable: true, get: function () { return basics_2.convertToDecimal; } });
21
23
  Object.defineProperty(exports, "getRandomNumber", { enumerable: true, get: function () { return basics_2.getRandomNumber; } });
24
+ Object.defineProperty(exports, "isEven", { enumerable: true, get: function () { return basics_2.isEven; } });
25
+ Object.defineProperty(exports, "isMultiple", { enumerable: true, get: function () { return basics_2.isMultiple; } });
26
+ Object.defineProperty(exports, "isOdd", { enumerable: true, get: function () { return basics_2.isOdd; } });
22
27
  var convert_2 = require("./number/convert");
23
28
  Object.defineProperty(exports, "numberToWords", { enumerable: true, get: function () { return convert_2.numberToWords; } });
24
29
  var prime_1 = require("./number/prime");
@@ -26,6 +31,7 @@ Object.defineProperty(exports, "findPrimeNumbers", { enumerable: true, get: func
26
31
  Object.defineProperty(exports, "isPrime", { enumerable: true, get: function () { return prime_1.isPrime; } });
27
32
  var range_1 = require("./number/range");
28
33
  Object.defineProperty(exports, "getNumbersInRange", { enumerable: true, get: function () { return range_1.getNumbersInRange; } });
34
+ // ! Color Utilities
29
35
  var initials_1 = require("./colors/initials");
30
36
  Object.defineProperty(exports, "getColorForInitial", { enumerable: true, get: function () { return initials_1.getColorForInitial; } });
31
37
  var random_1 = require("./colors/random");
@@ -48,6 +54,7 @@ Object.defineProperty(exports, "convertRgbToHsl", { enumerable: true, get: funct
48
54
  Object.defineProperty(exports, "convertRgbToRgba", { enumerable: true, get: function () { return convert_3.convertRgbToRgba; } });
49
55
  var Color_1 = require("./colors/Color");
50
56
  Object.defineProperty(exports, "Color", { enumerable: true, get: function () { return Color_1.Color; } });
57
+ // ! Array Utilities
51
58
  var basics_3 = require("./array/basics");
52
59
  Object.defineProperty(exports, "filterArrayOfObjects", { enumerable: true, get: function () { return basics_3.filterArrayOfObjects; } });
53
60
  Object.defineProperty(exports, "flattenArray", { enumerable: true, get: function () { return basics_3.flattenArray; } });
@@ -58,11 +65,13 @@ Object.defineProperty(exports, "sortAnArray", { enumerable: true, get: function
58
65
  var transform_1 = require("./array/transform");
59
66
  Object.defineProperty(exports, "createOptionsArray", { enumerable: true, get: function () { return transform_1.createOptionsArray; } });
60
67
  Object.defineProperty(exports, "removeDuplicatesFromArray", { enumerable: true, get: function () { return transform_1.removeDuplicatesFromArray; } });
68
+ // ! Form Utilities
61
69
  var convert_4 = require("./form/convert");
62
70
  Object.defineProperty(exports, "convertIntoFormData", { enumerable: true, get: function () { return convert_4.convertIntoFormData; } });
63
71
  Object.defineProperty(exports, "isEmptyFormData", { enumerable: true, get: function () { return convert_4.isEmptyFormData; } });
64
72
  var transform_2 = require("./form/transform");
65
73
  Object.defineProperty(exports, "createControlledFormData", { enumerable: true, get: function () { return transform_2.createControlledFormData; } });
74
+ // ! Object Utilities
66
75
  var basics_4 = require("./object/basics");
67
76
  Object.defineProperty(exports, "cloneObject", { enumerable: true, get: function () { return basics_4.cloneObject; } });
68
77
  Object.defineProperty(exports, "countObjectFields", { enumerable: true, get: function () { return basics_4.countObjectFields; } });
@@ -81,6 +90,7 @@ var sanitize_1 = require("./object/sanitize");
81
90
  Object.defineProperty(exports, "sanitizeData", { enumerable: true, get: function () { return sanitize_1.sanitizeData; } });
82
91
  var convert_5 = require("./object/convert");
83
92
  Object.defineProperty(exports, "convertObjectValues", { enumerable: true, get: function () { return convert_5.convertObjectValues; } });
93
+ // ! Other Utilities
84
94
  var utils_1 = require("./utils");
85
95
  Object.defineProperty(exports, "convertArrayToString", { enumerable: true, get: function () { return utils_1.convertArrayToString; } });
86
96
  Object.defineProperty(exports, "debounceAction", { enumerable: true, get: function () { return utils_1.debounceAction; } });
@@ -17,17 +17,39 @@ export declare const getRandomNumber: (options?: RandomNumberOptions) => number;
17
17
  */
18
18
  export declare const convertToDecimal: (num: number, options?: DecimalOptions) => number | string;
19
19
  /**
20
- * * Calculate the HCF/GCD of multiple numbers.
20
+ * * Calculates the HCF/GCD of multiple numbers.
21
21
  *
22
22
  * @param numbers - List of numbers to find the HCF/GCD for.
23
23
  * @returns The HCF/GCD of all the provided numbers.
24
24
  */
25
25
  export declare const calculateHCF: (...numbers: number[]) => number;
26
26
  /**
27
- * * Calculate the LCM/LCD of multiple numbers.
27
+ * * Calculates the LCM/LCD of multiple numbers.
28
28
  *
29
29
  * @param numbers - List of numbers to find the LCM/LCD for.
30
30
  * @returns The LCM/LCD of all the provided numbers.
31
31
  */
32
32
  export declare const calculateLCM: (...numbers: number[]) => number;
33
+ /**
34
+ * * Check if a number is even or not.
35
+ *
36
+ * @param input The number to check.
37
+ * @returns Boolean: `true` if even and `false` if not even.
38
+ */
39
+ export declare const isEven: (input: number) => boolean;
40
+ /**
41
+ * * Checks if a number is odd or not.
42
+ *
43
+ * @param input The number to check.
44
+ * @returns Boolean: `true` if odd and `false` if not odd.
45
+ */
46
+ export declare const isOdd: (input: number) => boolean;
47
+ /**
48
+ * * Checks if a number is a multiple of another number.
49
+ *
50
+ * @param input - The number to check.
51
+ * @param multipleOf - The number to check against.
52
+ * @returns `true` if `input` is a multiple of `multipleOf`, otherwise `false`.
53
+ */
54
+ export declare const isMultiple: (input: number, multipleOf: number) => boolean;
33
55
  //# sourceMappingURL=basics.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"basics.d.ts","sourceRoot":"","sources":["../../src/number/basics.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,cAAc,EAAE,mBAAmB,EAAE,MAAM,SAAS,CAAC;AAEnE;;;;;;;GAOG;AACH,eAAO,MAAM,eAAe,aAAc,mBAAmB,KAAG,MA+C/D,CAAC;AAEF;;;;;;GAMG;AACH,eAAO,MAAM,gBAAgB,QACvB,MAAM,YACD,cAAc,KACtB,MAAM,GAAG,MAQX,CAAC;AAEF;;;;;GAKG;AACH,eAAO,MAAM,YAAY,eAAgB,MAAM,EAAE,KAAG,MAQnD,CAAC;AAEF;;;;;GAKG;AACH,eAAO,MAAM,YAAY,eAAgB,MAAM,EAAE,KAAG,MAQnD,CAAC"}
1
+ {"version":3,"file":"basics.d.ts","sourceRoot":"","sources":["../../src/number/basics.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,cAAc,EAAE,mBAAmB,EAAE,MAAM,SAAS,CAAC;AAEnE;;;;;;;GAOG;AACH,eAAO,MAAM,eAAe,aAAc,mBAAmB,KAAG,MA+C/D,CAAC;AAEF;;;;;;GAMG;AACH,eAAO,MAAM,gBAAgB,QACvB,MAAM,YACD,cAAc,KACtB,MAAM,GAAG,MAQX,CAAC;AAEF;;;;;GAKG;AACH,eAAO,MAAM,YAAY,eAAgB,MAAM,EAAE,KAAG,MAQnD,CAAC;AAEF;;;;;GAKG;AACH,eAAO,MAAM,YAAY,eAAgB,MAAM,EAAE,KAAG,MAQnD,CAAC;AAEF;;;;;GAKG;AACH,eAAO,MAAM,MAAM,UAAW,MAAM,KAAG,OAEtC,CAAC;AAEF;;;;;GAKG;AACH,eAAO,MAAM,KAAK,UAAW,MAAM,KAAG,OAErC,CAAC;AAEF;;;;;;GAMG;AACH,eAAO,MAAM,UAAU,UAAW,MAAM,cAAc,MAAM,KAAG,OAE9D,CAAC"}
@@ -1,6 +1,6 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.calculateLCM = exports.calculateHCF = exports.convertToDecimal = exports.getRandomNumber = void 0;
3
+ exports.isMultiple = exports.isOdd = exports.isEven = exports.calculateLCM = exports.calculateHCF = exports.convertToDecimal = exports.getRandomNumber = void 0;
4
4
  const helpers_1 = require("./helpers");
5
5
  /**
6
6
  * * Utility to generate a random number between a given range.
@@ -60,7 +60,7 @@ const convertToDecimal = (num, options) => {
60
60
  };
61
61
  exports.convertToDecimal = convertToDecimal;
62
62
  /**
63
- * * Calculate the HCF/GCD of multiple numbers.
63
+ * * Calculates the HCF/GCD of multiple numbers.
64
64
  *
65
65
  * @param numbers - List of numbers to find the HCF/GCD for.
66
66
  * @returns The HCF/GCD of all the provided numbers.
@@ -74,7 +74,7 @@ const calculateHCF = (...numbers) => {
74
74
  };
75
75
  exports.calculateHCF = calculateHCF;
76
76
  /**
77
- * * Calculate the LCM/LCD of multiple numbers.
77
+ * * Calculates the LCM/LCD of multiple numbers.
78
78
  *
79
79
  * @param numbers - List of numbers to find the LCM/LCD for.
80
80
  * @returns The LCM/LCD of all the provided numbers.
@@ -87,3 +87,34 @@ const calculateLCM = (...numbers) => {
87
87
  return lcm;
88
88
  };
89
89
  exports.calculateLCM = calculateLCM;
90
+ /**
91
+ * * Check if a number is even or not.
92
+ *
93
+ * @param input The number to check.
94
+ * @returns Boolean: `true` if even and `false` if not even.
95
+ */
96
+ const isEven = (input) => {
97
+ return input % 2 === 0;
98
+ };
99
+ exports.isEven = isEven;
100
+ /**
101
+ * * Checks if a number is odd or not.
102
+ *
103
+ * @param input The number to check.
104
+ * @returns Boolean: `true` if odd and `false` if not odd.
105
+ */
106
+ const isOdd = (input) => {
107
+ return input % 2 !== 0;
108
+ };
109
+ exports.isOdd = isOdd;
110
+ /**
111
+ * * Checks if a number is a multiple of another number.
112
+ *
113
+ * @param input - The number to check.
114
+ * @param multipleOf - The number to check against.
115
+ * @returns `true` if `input` is a multiple of `multipleOf`, otherwise `false`.
116
+ */
117
+ const isMultiple = (input, multipleOf) => {
118
+ return input % multipleOf === 0;
119
+ };
120
+ exports.isMultiple = isMultiple;
@@ -1 +1 @@
1
- {"version":3,"file":"convert.d.ts","sourceRoot":"","sources":["../../src/number/convert.ts"],"names":[],"mappings":"AAEA;;;;GAIG;AACH,wBAAgB,aAAa,CAAC,MAAM,EAAE,MAAM,GAAG,MAAM,CAsDpD"}
1
+ {"version":3,"file":"convert.d.ts","sourceRoot":"","sources":["../../src/number/convert.ts"],"names":[],"mappings":"AAGA;;;;GAIG;AACH,wBAAgB,aAAa,CAAC,MAAM,EAAE,MAAM,GAAG,MAAM,CA0BpD"}
@@ -2,6 +2,7 @@
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.numberToWords = numberToWords;
4
4
  const constants_1 = require("./constants");
5
+ const helpers_1 = require("./helpers");
5
6
  /**
6
7
  * * Converts a number to words
7
8
  * @param number - The number to convert into words.
@@ -12,35 +13,12 @@ function numberToWords(number) {
12
13
  if (number === 0)
13
14
  return 'zero';
14
15
  number = Math.abs(number);
15
- /**
16
- * - Converts a number less than 1000 to words.
17
- * @param num - The number to convert (less than 1000).
18
- * @param isLast - Whether this is the last group (thousands, millions, etc.).
19
- * @returns Numbers less than 1000 in words.
20
- */
21
- function _convertLessThanThousand(num, isLast) {
22
- if (num < 10)
23
- return constants_1.ones[num];
24
- if (num < 20)
25
- return constants_1.teens[num - 10];
26
- let result = constants_1.tens[Math.floor(num / 10)];
27
- const remainder = num % 10;
28
- if (remainder > 0)
29
- result += `-${constants_1.ones[remainder]}`;
30
- if (num >= 100) {
31
- const hundredsPart = `${constants_1.ones[Math.floor(num / 100)]} hundred`;
32
- return num % 100 === 0 ?
33
- hundredsPart
34
- : `${hundredsPart} ${isLast ? 'and' : ''} ${_convertLessThanThousand(num % 100, false)}`;
35
- }
36
- return result;
37
- }
38
16
  let i = 0;
39
17
  let result = '';
40
18
  while (number > 0) {
41
19
  if (number % 1000 !== 0) {
42
20
  const isLastGroup = i === 0 && number % 100 < 100;
43
- const prefix = _convertLessThanThousand(number % 1000, isLastGroup);
21
+ const prefix = (0, helpers_1._convertLessThanThousand)(number % 1000, isLastGroup);
44
22
  result = `${prefix} ${constants_1.thousands[i]} ${result}`;
45
23
  }
46
24
  number = Math.floor(number / 1000);
@@ -1,3 +1,17 @@
1
+ /**
2
+ * Apply multiples of a number if there is any.
3
+ * @param array Array of numbers to apply the condition on.
4
+ * @param multiples The multiples of which number.
5
+ * @returns Array of multiples of the desired number
6
+ */
7
+ export declare const _applyMultiples: (array: number[], multiples?: number) => number[];
8
+ /**
9
+ * - Converts a number less than 1000 to words.
10
+ * @param num - The number to convert (less than 1000).
11
+ * @param isLast - Whether this is the last group (thousands, millions, etc.).
12
+ * @returns Numbers less than 1000 in words.
13
+ */
14
+ export declare function _convertLessThanThousand(num: number, isLast: boolean): string;
1
15
  /**
2
16
  * * Calculate the HCF (Highest Common Factor) of two numbers using the Euclidean algorithm.
3
17
  *
@@ -1 +1 @@
1
- {"version":3,"file":"helpers.d.ts","sourceRoot":"","sources":["../../src/number/helpers.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AACH,eAAO,MAAM,gBAAgB,MAAO,MAAM,KAAK,MAAM,KAAG,MAYvD,CAAC;AAEF;;;;;;GAMG;AACH,eAAO,MAAM,gBAAgB,MAAO,MAAM,KAAK,MAAM,KAAG,MAKvD,CAAC"}
1
+ {"version":3,"file":"helpers.d.ts","sourceRoot":"","sources":["../../src/number/helpers.ts"],"names":[],"mappings":"AAEA;;;;;GAKG;AACH,eAAO,MAAM,eAAe,UACpB,MAAM,EAAE,cACH,MAAM,KAChB,MAAM,EAGR,CAAC;AAEF;;;;;GAKG;AACH,wBAAgB,wBAAwB,CAAC,GAAG,EAAE,MAAM,EAAE,MAAM,EAAE,OAAO,GAAG,MAAM,CAoB7E;AAED;;;;;;GAMG;AACH,eAAO,MAAM,gBAAgB,MAAO,MAAM,KAAK,MAAM,KAAG,MAYvD,CAAC;AAEF;;;;;;GAMG;AACH,eAAO,MAAM,gBAAgB,MAAO,MAAM,KAAK,MAAM,KAAG,MAKvD,CAAC"}
@@ -1,6 +1,43 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports._find2NumbersLCM = exports._find2NumbersHCF = void 0;
3
+ exports._find2NumbersLCM = exports._find2NumbersHCF = exports._applyMultiples = void 0;
4
+ exports._convertLessThanThousand = _convertLessThanThousand;
5
+ const constants_1 = require("./constants");
6
+ /**
7
+ * Apply multiples of a number if there is any.
8
+ * @param array Array of numbers to apply the condition on.
9
+ * @param multiples The multiples of which number.
10
+ * @returns Array of multiples of the desired number
11
+ */
12
+ const _applyMultiples = (array, multiples) => {
13
+ if (!multiples)
14
+ return array;
15
+ return array.filter((n) => n % multiples === 0);
16
+ };
17
+ exports._applyMultiples = _applyMultiples;
18
+ /**
19
+ * - Converts a number less than 1000 to words.
20
+ * @param num - The number to convert (less than 1000).
21
+ * @param isLast - Whether this is the last group (thousands, millions, etc.).
22
+ * @returns Numbers less than 1000 in words.
23
+ */
24
+ function _convertLessThanThousand(num, isLast) {
25
+ if (num < 10)
26
+ return constants_1.ones[num];
27
+ if (num < 20)
28
+ return constants_1.teens[num - 10];
29
+ let result = constants_1.tens[Math.floor(num / 10)];
30
+ const remainder = num % 10;
31
+ if (remainder > 0)
32
+ result += `-${constants_1.ones[remainder]}`;
33
+ if (num >= 100) {
34
+ const hundredsPart = `${constants_1.ones[Math.floor(num / 100)]} hundred`;
35
+ return num % 100 === 0 ?
36
+ hundredsPart
37
+ : `${hundredsPart} ${isLast ? 'and' : ''} ${_convertLessThanThousand(num % 100, false)}`;
38
+ }
39
+ return result;
40
+ }
4
41
  /**
5
42
  * * Calculate the HCF (Highest Common Factor) of two numbers using the Euclidean algorithm.
6
43
  *
@@ -1 +1 @@
1
- {"version":3,"file":"range.d.ts","sourceRoot":"","sources":["../../src/number/range.ts"],"names":[],"mappings":"AAIA,OAAO,KAAK,EAAE,KAAK,EAAE,UAAU,EAAE,aAAa,EAAE,YAAY,EAAE,MAAM,SAAS,CAAC;AAE9E;;;;;;;GAOG;AACH,wBAAgB,iBAAiB,CAAC,CAAC,SAAS,KAAK,EAChD,IAAI,GAAE,UAAkB,EACxB,OAAO,CAAC,EAAE,YAAY,CAAC,CAAC,CAAC,GACvB,aAAa,CAAC,CAAC,CAAC,CAsGlB"}
1
+ {"version":3,"file":"range.d.ts","sourceRoot":"","sources":["../../src/number/range.ts"],"names":[],"mappings":"AAKA,OAAO,KAAK,EAAE,KAAK,EAAE,UAAU,EAAE,aAAa,EAAE,YAAY,EAAE,MAAM,SAAS,CAAC;AAE9E;;;;;;;GAOG;AACH,wBAAgB,iBAAiB,CAAC,CAAC,SAAS,KAAK,EAChD,IAAI,GAAE,UAAkB,EACxB,OAAO,CAAC,EAAE,YAAY,CAAC,CAAC,CAAC,GACvB,aAAa,CAAC,CAAC,CAAC,CA2FlB"}
@@ -4,6 +4,7 @@ exports.getNumbersInRange = getNumbersInRange;
4
4
  const basics_1 = require("../array/basics");
5
5
  const utils_1 = require("../utils");
6
6
  const basics_2 = require("./basics");
7
+ const helpers_1 = require("./helpers");
7
8
  const prime_1 = require("./prime");
8
9
  /**
9
10
  * * Function to get numbers within a range based on the provided `NumberType` and options.
@@ -16,17 +17,6 @@ const prime_1 = require("./prime");
16
17
  function getNumbersInRange(type = 'any', options) {
17
18
  const { getAs = 'array', min = 0, max = 100, includeMin = true, includeMax = true, separator = ',', multiples, } = options || {};
18
19
  let output = [];
19
- /**
20
- * Apply multiples of a number if there is any.
21
- * @param array Array of numbers to apply the condition on.
22
- * @param multiples The multiples of which number.
23
- * @returns Array of multiples of the desired number
24
- */
25
- const _applyMultiples = (array, multiples) => {
26
- if (!multiples)
27
- return array;
28
- return array.filter((n) => n % multiples === 0);
29
- };
30
20
  /**
31
21
  * Helper function to apply range and get array of numbers in that range.
32
22
  *
@@ -42,10 +32,10 @@ function getNumbersInRange(type = 'any', options) {
42
32
  }
43
33
  const numbers = [];
44
34
  for (let i = startNumber; i <= endNumber; i++) {
45
- if (i >= min &&
46
- i <= max &&
47
- (includeMin || i > min) &&
48
- (includeMax || i < max)) {
35
+ if (i >= startNumber &&
36
+ i <= endNumber &&
37
+ (includeMin || i > startNumber) &&
38
+ (includeMax || i < endNumber)) {
49
39
  numbers.push(i);
50
40
  }
51
41
  }
@@ -67,10 +57,10 @@ function getNumbersInRange(type = 'any', options) {
67
57
  output = _applyRangeOptions(min, max).filter(prime_1.isPrime);
68
58
  break;
69
59
  case 'odd':
70
- output = _applyRangeOptions(min, max).filter((i) => i % 2 !== 0);
60
+ output = _applyRangeOptions(min, max).filter(basics_2.isOdd);
71
61
  break;
72
62
  case 'even':
73
- output = _applyRangeOptions(min, max).filter((i) => i % 2 === 0);
63
+ output = _applyRangeOptions(min, max).filter(basics_2.isEven);
74
64
  break;
75
65
  case 'natural':
76
66
  output = _applyRangeOptions(Math.max(min, 1), max);
@@ -80,7 +70,7 @@ function getNumbersInRange(type = 'any', options) {
80
70
  break;
81
71
  }
82
72
  if (type !== 'prime') {
83
- output = _applyMultiples(output, multiples);
73
+ output = (0, helpers_1._applyMultiples)(output, multiples);
84
74
  }
85
75
  return getAs === 'string' ?
86
76
  (0, utils_1.convertArrayToString)(output, separator)
@@ -1,13 +1,13 @@
1
- import type { CapitalizeOptions, RandomIdOptions } from './types';
1
+ import type { CapitalizeOptions, CapitalizeResult, RandomIdOptions } from './types';
2
2
  /**
3
3
  * * Utility to convert the first letter of any string to uppercase and the rest lowercase (unless specified).
4
- * Handles surrounding symbols like quotes or parentheses.
4
+ * * Handles surrounding symbols like quotes or parentheses.
5
5
  *
6
6
  * @param string String to be capitalized.
7
7
  * @param options Options to customize the capitalization.
8
- * @returns Capitalized string.
8
+ * @returns Capitalized string or fully uppercased string depending on `capitalizeAll` option.
9
9
  */
10
- export declare const capitalizeString: (string: string, options?: CapitalizeOptions) => string;
10
+ export declare function capitalizeString<T extends string, O extends CapitalizeOptions>(string: T, options?: O): CapitalizeResult<T, O>;
11
11
  /**
12
12
  * * Utility to truncate a string to a specified length.
13
13
  *
@@ -1 +1 @@
1
- {"version":3,"file":"basics.d.ts","sourceRoot":"","sources":["../../src/string/basics.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,iBAAiB,EAAE,eAAe,EAAE,MAAM,SAAS,CAAC;AAElE;;;;;;;GAOG;AACH,eAAO,MAAM,gBAAgB,WACpB,MAAM,YACJ,iBAAiB,KACzB,MA0CF,CAAC;AAEF;;;;;;GAMG;AACH,eAAO,MAAM,cAAc,WAAY,MAAM,aAAa,MAAM,KAAG,MAUlE,CAAC;AAEF;;;;;GAKG;AACH,eAAO,MAAM,gBAAgB,aAAc,eAAe,KAAG,MAmC5D,CAAC;AAEF;;;;;GAKG;AACH,wBAAgB,UAAU,CAAC,KAAK,EAAE,MAAM,GAAG,MAAM,CAAC;AAElD;;;;;GAKG;AACH,wBAAgB,UAAU,CAAC,KAAK,EAAE,MAAM,EAAE,GAAG,MAAM,EAAE,CAAC"}
1
+ {"version":3,"file":"basics.d.ts","sourceRoot":"","sources":["../../src/string/basics.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACX,iBAAiB,EACjB,gBAAgB,EAChB,eAAe,EACf,MAAM,SAAS,CAAC;AAEjB;;;;;;;GAOG;AACH,wBAAgB,gBAAgB,CAAC,CAAC,SAAS,MAAM,EAAE,CAAC,SAAS,iBAAiB,EAC7E,MAAM,EAAE,CAAC,EACT,OAAO,CAAC,EAAE,CAAC,GACT,gBAAgB,CAAC,CAAC,EAAE,CAAC,CAAC,CA2CxB;AAED;;;;;;GAMG;AACH,eAAO,MAAM,cAAc,WAAY,MAAM,aAAa,MAAM,KAAG,MAUlE,CAAC;AAEF;;;;;GAKG;AACH,eAAO,MAAM,gBAAgB,aAAc,eAAe,KAAG,MAmC5D,CAAC;AAEF;;;;;GAKG;AACH,wBAAgB,UAAU,CAAC,KAAK,EAAE,MAAM,GAAG,MAAM,CAAC;AAElD;;;;;GAKG;AACH,wBAAgB,UAAU,CAAC,KAAK,EAAE,MAAM,EAAE,GAAG,MAAM,EAAE,CAAC"}
@@ -1,16 +1,17 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.generateRandomID = exports.truncateString = exports.capitalizeString = void 0;
3
+ exports.generateRandomID = exports.truncateString = void 0;
4
+ exports.capitalizeString = capitalizeString;
4
5
  exports.trimString = trimString;
5
6
  /**
6
7
  * * Utility to convert the first letter of any string to uppercase and the rest lowercase (unless specified).
7
- * Handles surrounding symbols like quotes or parentheses.
8
+ * * Handles surrounding symbols like quotes or parentheses.
8
9
  *
9
10
  * @param string String to be capitalized.
10
11
  * @param options Options to customize the capitalization.
11
- * @returns Capitalized string.
12
+ * @returns Capitalized string or fully uppercased string depending on `capitalizeAll` option.
12
13
  */
13
- const capitalizeString = (string, options) => {
14
+ function capitalizeString(string, options) {
14
15
  if (typeof string !== 'string' || !string)
15
16
  return '';
16
17
  const trimmedString = string.trim();
@@ -23,7 +24,7 @@ const capitalizeString = (string, options) => {
23
24
  if (capitalizeEachFirst) {
24
25
  return trimmedString
25
26
  .split(/\s+/)
26
- .map((word) => (0, exports.capitalizeString)(word, { lowerCaseRest }))
27
+ .map((word) => capitalizeString(word, { lowerCaseRest }))
27
28
  .join(' ');
28
29
  }
29
30
  const matchArray = trimmedString.match(/^(\W*)(\w)(.*)$/);
@@ -39,8 +40,7 @@ const capitalizeString = (string, options) => {
39
40
  .concat(lowerCaseRest ?
40
41
  trimmedString.slice(1).toLowerCase()
41
42
  : trimmedString.slice(1));
42
- };
43
- exports.capitalizeString = capitalizeString;
43
+ }
44
44
  /**
45
45
  * * Utility to truncate a string to a specified length.
46
46
  *
@@ -7,6 +7,10 @@ export interface CapitalizeOptions {
7
7
  /** If true, ensures that the rest of the string is lowercase. Defaults to `true`. */
8
8
  lowerCaseRest?: boolean;
9
9
  }
10
+ /** - Capitalizes the first letter of each word. */
11
+ type CapitalizeWords<T extends string, LowerCaseRest extends boolean> = T extends `${infer First} ${infer Rest}` ? `${Capitalize<First>} ${CapitalizeWords<Rest, LowerCaseRest>}` : Capitalize<T>;
12
+ /** - Determines the correct return type based on the provided options. */
13
+ export type CapitalizeResult<T extends string, O extends CapitalizeOptions> = O['capitalizeAll'] extends true ? Uppercase<T> : O['capitalizeEachFirst'] extends true ? CapitalizeWords<O['lowerCaseRest'] extends false ? T : Lowercase<T>, O['lowerCaseRest'] extends boolean ? O['lowerCaseRest'] : true> : O['lowerCaseRest'] extends false ? Capitalize<T> : Capitalize<Lowercase<T>>;
10
14
  /** - Configuration options for ID generation. */
11
15
  export interface RandomIdOptions {
12
16
  /** A string to prepend to the ID. Default is an empty string. */
@@ -29,4 +33,5 @@ export interface AnagramOptions {
29
33
  /** Whether to lookup in the dictionary. Default is `false`. */
30
34
  validWords?: boolean;
31
35
  }
36
+ export {};
32
37
  //# sourceMappingURL=types.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../src/string/types.ts"],"names":[],"mappings":"AAAA,iDAAiD;AACjD,MAAM,WAAW,iBAAiB;IACjC,iGAAiG;IACjG,mBAAmB,CAAC,EAAE,OAAO,CAAC;IAC9B,kFAAkF;IAClF,aAAa,CAAC,EAAE,OAAO,CAAC;IACxB,qFAAqF;IACrF,aAAa,CAAC,EAAE,OAAO,CAAC;CACxB;AAED,iDAAiD;AACjD,MAAM,WAAW,eAAe;IAC/B,iEAAiE;IACjE,MAAM,CAAC,EAAE,MAAM,CAAC;IAEhB,+DAA+D;IAC/D,MAAM,CAAC,EAAE,MAAM,CAAC;IAEhB,8EAA8E;IAC9E,SAAS,CAAC,EAAE,OAAO,CAAC;IAEpB,qEAAqE;IACrE,MAAM,CAAC,EAAE,MAAM,CAAC;IAEhB,gFAAgF;IAChF,SAAS,CAAC,EAAE,MAAM,CAAC;IAEnB,gFAAgF;IAChF,UAAU,CAAC,EAAE,OAAO,GAAG,OAAO,GAAG,IAAI,CAAC;CACtC;AAED,yCAAyC;AACzC,MAAM,WAAW,cAAc;IAC9B,mDA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AM,CAAC,EAAE,MAAM,CAAC;IAEhB,+DAA+D;IAC/D,MAAM,CAAC,EAAE,MAAM,CAAC;IAEhB,8EAA8E;IAC9E,SAAS,CAAC,EAAE,OAAO,CAAC;IAEpB,qEAAqE;IACrE,MAAM,CAAC,EAAE,MAAM,CAAC;IAEhB,gFAAgF;IAChF,SAAS,CAAC,EAAE,MAAM,CAAC;IAEnB,gFAAgF;IAChF,UAAU,CAAC,EAAE,OAAO,GAAG,OAAO,GAAG,IAAI,CAAC;CACtC;AAED,yCAAyC;AACzC,MAAM,WAAW,cAAc;IAC9B,mDAAmD;IACnD,KAAK,CAAC,EAAE,MAAM,GAAG,KAAK,CAAC;IACvB,+DAA+D;IAC/D,UAAU,CAAC,EAAE,OAAO,CAAC;CACrB"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "nhb-toolbox",
3
- "version": "2.2.9",
3
+ "version": "2.3.3",
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",