nhb-toolbox 2.2.2 → 2.2.9
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 +1 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +6 -2
- package/dist/number/basics.d.ts +14 -0
- package/dist/number/basics.d.ts.map +1 -1
- package/dist/number/basics.js +30 -1
- package/dist/number/helpers.d.ts +17 -0
- package/dist/number/helpers.d.ts.map +1 -0
- package/dist/number/helpers.js +34 -0
- package/package.json +1 -1
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 { convertToDecimal, getRandomNumber } from './number/basics';
|
|
4
|
+
export { calculateHCF as calculateGCD, calculateHCF, calculateLCM as calculateLCD, calculateLCM, convertToDecimal, getRandomNumber, } 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';
|
package/dist/index.d.ts.map
CHANGED
|
@@ -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,
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EACN,gBAAgB,EAChB,gBAAgB,EAChB,UAAU,EAC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BAAmB,EACnB,aAAa,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;AAEvD,OAAO,EACN,oBAAoB,EACpB,cAAc,EACd,WAAW,EACX,cAAc,GACd,MAAM,SAAS,CAAC"}
|
package/dist/index.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.
|
|
4
|
-
exports.throttleAction = exports.isDeepEqual = exports.debounceAction = exports.convertArrayToString = exports.convertObjectValues = exports.sanitizeData = exports.mergeObjects = exports.mergeAndFlattenObjects = exports.flattenObjectKeyValue = void 0;
|
|
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;
|
|
5
5
|
var basics_1 = require("./string/basics");
|
|
6
6
|
Object.defineProperty(exports, "capitalizeString", { enumerable: true, get: function () { return basics_1.capitalizeString; } });
|
|
7
7
|
Object.defineProperty(exports, "generateRandomID", { enumerable: true, get: function () { return basics_1.generateRandomID; } });
|
|
@@ -13,6 +13,10 @@ var convert_1 = require("./string/convert");
|
|
|
13
13
|
Object.defineProperty(exports, "convertStringCase", { enumerable: true, get: function () { return convert_1.convertStringCase; } });
|
|
14
14
|
Object.defineProperty(exports, "replaceAllInString", { enumerable: true, get: function () { return convert_1.replaceAllInString; } });
|
|
15
15
|
var basics_2 = require("./number/basics");
|
|
16
|
+
Object.defineProperty(exports, "calculateGCD", { enumerable: true, get: function () { return basics_2.calculateHCF; } });
|
|
17
|
+
Object.defineProperty(exports, "calculateHCF", { enumerable: true, get: function () { return basics_2.calculateHCF; } });
|
|
18
|
+
Object.defineProperty(exports, "calculateLCD", { enumerable: true, get: function () { return basics_2.calculateLCM; } });
|
|
19
|
+
Object.defineProperty(exports, "calculateLCM", { enumerable: true, get: function () { return basics_2.calculateLCM; } });
|
|
16
20
|
Object.defineProperty(exports, "convertToDecimal", { enumerable: true, get: function () { return basics_2.convertToDecimal; } });
|
|
17
21
|
Object.defineProperty(exports, "getRandomNumber", { enumerable: true, get: function () { return basics_2.getRandomNumber; } });
|
|
18
22
|
var convert_2 = require("./number/convert");
|
package/dist/number/basics.d.ts
CHANGED
|
@@ -16,4 +16,18 @@ export declare const getRandomNumber: (options?: RandomNumberOptions) => number;
|
|
|
16
16
|
* @returns Converted number (as a `number`) or string (if `isString` is `true`).
|
|
17
17
|
*/
|
|
18
18
|
export declare const convertToDecimal: (num: number, options?: DecimalOptions) => number | string;
|
|
19
|
+
/**
|
|
20
|
+
* * Calculate the HCF/GCD of multiple numbers.
|
|
21
|
+
*
|
|
22
|
+
* @param numbers - List of numbers to find the HCF/GCD for.
|
|
23
|
+
* @returns The HCF/GCD of all the provided numbers.
|
|
24
|
+
*/
|
|
25
|
+
export declare const calculateHCF: (...numbers: number[]) => number;
|
|
26
|
+
/**
|
|
27
|
+
* * Calculate the LCM/LCD of multiple numbers.
|
|
28
|
+
*
|
|
29
|
+
* @param numbers - List of numbers to find the LCM/LCD for.
|
|
30
|
+
* @returns The LCM/LCD of all the provided numbers.
|
|
31
|
+
*/
|
|
32
|
+
export declare const calculateLCM: (...numbers: number[]) => number;
|
|
19
33
|
//# sourceMappingURL=basics.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"basics.d.ts","sourceRoot":"","sources":["../../src/number/basics.ts"],"names":[],"mappings":"
|
|
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"}
|
package/dist/number/basics.js
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.convertToDecimal = exports.getRandomNumber = void 0;
|
|
3
|
+
exports.calculateLCM = exports.calculateHCF = exports.convertToDecimal = exports.getRandomNumber = void 0;
|
|
4
|
+
const helpers_1 = require("./helpers");
|
|
4
5
|
/**
|
|
5
6
|
* * Utility to generate a random number between a given range.
|
|
6
7
|
* * If no options are provided, it will generate a random number between `0` and `100` (inclusive).
|
|
@@ -58,3 +59,31 @@ const convertToDecimal = (num, options) => {
|
|
|
58
59
|
return parseFloat(num.toFixed(decimalPlaces));
|
|
59
60
|
};
|
|
60
61
|
exports.convertToDecimal = convertToDecimal;
|
|
62
|
+
/**
|
|
63
|
+
* * Calculate the HCF/GCD of multiple numbers.
|
|
64
|
+
*
|
|
65
|
+
* @param numbers - List of numbers to find the HCF/GCD for.
|
|
66
|
+
* @returns The HCF/GCD of all the provided numbers.
|
|
67
|
+
*/
|
|
68
|
+
const calculateHCF = (...numbers) => {
|
|
69
|
+
let hcf = numbers[0];
|
|
70
|
+
for (let i = 1; i < numbers.length; i++) {
|
|
71
|
+
hcf = (0, helpers_1._find2NumbersHCF)(hcf, numbers[i]);
|
|
72
|
+
}
|
|
73
|
+
return hcf;
|
|
74
|
+
};
|
|
75
|
+
exports.calculateHCF = calculateHCF;
|
|
76
|
+
/**
|
|
77
|
+
* * Calculate the LCM/LCD of multiple numbers.
|
|
78
|
+
*
|
|
79
|
+
* @param numbers - List of numbers to find the LCM/LCD for.
|
|
80
|
+
* @returns The LCM/LCD of all the provided numbers.
|
|
81
|
+
*/
|
|
82
|
+
const calculateLCM = (...numbers) => {
|
|
83
|
+
let lcm = numbers[0];
|
|
84
|
+
for (let i = 1; i < numbers.length; i++) {
|
|
85
|
+
lcm = (0, helpers_1._find2NumbersLCM)(lcm, numbers[i]);
|
|
86
|
+
}
|
|
87
|
+
return lcm;
|
|
88
|
+
};
|
|
89
|
+
exports.calculateLCM = calculateLCM;
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* * Calculate the HCF (Highest Common Factor) of two numbers using the Euclidean algorithm.
|
|
3
|
+
*
|
|
4
|
+
* @param a - First number.
|
|
5
|
+
* @param b - Second number.
|
|
6
|
+
* @returns The HCF of the two numbers.
|
|
7
|
+
*/
|
|
8
|
+
export declare const _find2NumbersHCF: (a: number, b: number) => number;
|
|
9
|
+
/**
|
|
10
|
+
* * Calculate the LCM (Least Common Multiple) of two numbers using the Euclidean algorithm.
|
|
11
|
+
*
|
|
12
|
+
* @param a - First number.
|
|
13
|
+
* @param b - Second number.
|
|
14
|
+
* @returns The LCM of the two numbers.
|
|
15
|
+
*/
|
|
16
|
+
export declare const _find2NumbersLCM: (a: number, b: number) => number;
|
|
17
|
+
//# sourceMappingURL=helpers.d.ts.map
|
|
@@ -0,0 +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"}
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports._find2NumbersLCM = exports._find2NumbersHCF = void 0;
|
|
4
|
+
/**
|
|
5
|
+
* * Calculate the HCF (Highest Common Factor) of two numbers using the Euclidean algorithm.
|
|
6
|
+
*
|
|
7
|
+
* @param a - First number.
|
|
8
|
+
* @param b - Second number.
|
|
9
|
+
* @returns The HCF of the two numbers.
|
|
10
|
+
*/
|
|
11
|
+
const _find2NumbersHCF = (a, b) => {
|
|
12
|
+
let x = Math.abs(a);
|
|
13
|
+
let y = Math.abs(b);
|
|
14
|
+
while (y !== 0) {
|
|
15
|
+
const temp = y;
|
|
16
|
+
y = x % y;
|
|
17
|
+
x = temp;
|
|
18
|
+
}
|
|
19
|
+
return x;
|
|
20
|
+
};
|
|
21
|
+
exports._find2NumbersHCF = _find2NumbersHCF;
|
|
22
|
+
/**
|
|
23
|
+
* * Calculate the LCM (Least Common Multiple) of two numbers using the Euclidean algorithm.
|
|
24
|
+
*
|
|
25
|
+
* @param a - First number.
|
|
26
|
+
* @param b - Second number.
|
|
27
|
+
* @returns The LCM of the two numbers.
|
|
28
|
+
*/
|
|
29
|
+
const _find2NumbersLCM = (a, b) => {
|
|
30
|
+
const x = Math.abs(a);
|
|
31
|
+
const y = Math.abs(b);
|
|
32
|
+
return (x * y) / (0, exports._find2NumbersHCF)(x, y);
|
|
33
|
+
};
|
|
34
|
+
exports._find2NumbersLCM = _find2NumbersLCM;
|
package/package.json
CHANGED