nhb-toolbox 4.0.24 → 4.0.30
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/date/Chronos.js +4 -6
- package/dist/cjs/index.js +30 -12
- package/dist/cjs/number/basics.js +86 -20
- package/dist/cjs/number/convert.js +6 -4
- package/dist/cjs/number/fibonacci.js +89 -0
- package/dist/cjs/number/utilities.js +7 -7
- package/dist/dts/date/Chronos.d.ts +2 -2
- package/dist/dts/date/Chronos.d.ts.map +1 -1
- package/dist/dts/index.d.ts +4 -3
- package/dist/dts/index.d.ts.map +1 -1
- package/dist/dts/number/basics.d.ts +35 -9
- package/dist/dts/number/basics.d.ts.map +1 -1
- package/dist/dts/number/convert.d.ts +3 -2
- package/dist/dts/number/convert.d.ts.map +1 -1
- package/dist/dts/number/fibonacci.d.ts +31 -0
- package/dist/dts/number/fibonacci.d.ts.map +1 -0
- package/dist/dts/number/utilities.d.ts +5 -5
- package/dist/dts/number/utilities.d.ts.map +1 -1
- package/dist/esm/date/Chronos.js +4 -6
- package/dist/esm/index.js +4 -3
- package/dist/esm/number/basics.js +82 -19
- package/dist/esm/number/convert.js +6 -4
- package/dist/esm/number/fibonacci.js +83 -0
- package/dist/esm/number/utilities.js +7 -7
- package/package.json +1 -1
package/dist/cjs/date/Chronos.js
CHANGED
|
@@ -47,14 +47,12 @@ class Chronos {
|
|
|
47
47
|
* @returns Instance of `Chronos` with all methods and properties.
|
|
48
48
|
*/
|
|
49
49
|
constructor(valueOrYear, month, date, hours, minutes, seconds, ms) {
|
|
50
|
-
let newDate;
|
|
51
50
|
if (typeof valueOrYear === 'number' && typeof month === 'number') {
|
|
52
|
-
|
|
51
|
+
this.#date = new Date(valueOrYear, month - 1, date ?? 1, hours ?? 0, minutes ?? 0, seconds ?? 0, ms ?? 0);
|
|
53
52
|
}
|
|
54
53
|
else {
|
|
55
|
-
|
|
54
|
+
this.#date = this.#toNewDate(valueOrYear);
|
|
56
55
|
}
|
|
57
|
-
this.#date = newDate;
|
|
58
56
|
this[constants_1.ORIGIN] = 'root';
|
|
59
57
|
this.#offset = `UTC${this.getUTCOffset()}`;
|
|
60
58
|
}
|
|
@@ -1416,9 +1414,9 @@ class Chronos {
|
|
|
1416
1414
|
* * Rounds the current date-time to the nearest specified unit and interval.
|
|
1417
1415
|
*
|
|
1418
1416
|
* @param unit - The unit to round (`year`, `month`, `week`, `day`, `hour`, `minute`, `second`, `millisecond`).
|
|
1419
|
-
*
|
|
1417
|
+
*
|
|
1420
1418
|
* @param nearest - The interval to round to. Defaults to `1`.
|
|
1421
|
-
* @returns A new `Chronos` instance with the rounded value. For wrong unit returns current instance.
|
|
1419
|
+
* @returns A new `Chronos` instance with the rounded value. For wrong unit returns current instance. Rounded *Month and Week are 0 based.*
|
|
1422
1420
|
*/
|
|
1423
1421
|
round(unit, nearest = 1) {
|
|
1424
1422
|
const date = new Date(this.#date);
|
package/dist/cjs/index.js
CHANGED
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.
|
|
4
|
-
exports.
|
|
5
|
-
exports.
|
|
6
|
-
exports.
|
|
7
|
-
exports.
|
|
8
|
-
exports.isValidURL = exports.isValidEmail = exports.isUUID = exports.isURL = exports.isPhoneNumber = void 0;
|
|
3
|
+
exports.getFibonacci = exports.generateFibonacci = exports.fibonacciGenerator = exports.sumOfNumbers = exports.sumNumbers = exports.sumDigits = exports.reverseNumber = exports.percentageOfWhat = exports.getValueFromPercentage = exports.getSumOfNumbers = exports.getRandomNumber = exports.getPercentageResult = exports.getPercentageOfWhat = exports.getPercentage = exports.getOriginalNumberFromPercentage = exports.getAverageOfNumbers = exports.getAverage = exports.convertToDecimal = exports.calculatePercentage = exports.calculateOriginalFromPercentage = exports.calculateLCM = exports.calculateLCD = exports.calculateHCF = exports.calculateGCD = exports.calculateAverage = exports.levenshteinDistance = exports.getLevenshteinDistance = exports.extractNumbersFromString = 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;
|
|
4
|
+
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.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.numberToWords = exports.convertToRomanNumerals = exports.convertNumberToWords = exports.isPerfectSquare = exports.isParOfFibonacciSeries = exports.isParOfFibonacci = exports.isOddNumber = exports.isOdd = exports.isMultiple = exports.isFibonacci = exports.isEvenNumber = exports.isEven = exports.getNthFibonacci = exports.getMemoizedFibonacciSeries = exports.getMemoizedFibonacci = exports.getFibonacciSeriesMemo = exports.getFibonacciSeries = exports.getFibonacciNumbers = void 0;
|
|
5
|
+
exports.splitArray = exports.rotateArray = exports.removeDuplicatesFromArray = exports.moveArrayElement = exports.createOptionsArray = exports.sortAnArray = exports.shuffleArray = exports.isValidEmptyArray = exports.isInvalidOrEmptyArray = exports.getLastArrayElement = exports.flattenArray = exports.filterArrayOfObjects = exports.minutesToUTCOffset = exports.getTotalMinutesFromUTC = 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.Colour = exports.Color = exports.convertRgbToRgba = exports.convertRgbToHsl = exports.convertRgbToHex = exports.convertRgbaToHsla = exports.convertRgbaToHex8 = void 0;
|
|
6
|
+
exports.removeFromLocalStorage = exports.getFromSessionStorage = exports.getFromLocalStorage = exports.toggleFullScreen = exports.smoothScrollTo = exports.copyToClipboard = exports.updateQueryParam = 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 = exports.parseObjectValues = 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 = void 0;
|
|
7
|
+
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 = exports.isNonEmptyString = exports.isInteger = exports.isFalsy = exports.isBoolean = exports.throttleAction = exports.isDeepEqual = exports.getStaticMethodsCount = exports.getStaticMethodNames = exports.getInstanceMethodsCount = exports.getInstanceMethodNames = exports.getClassDetails = exports.debounceAction = exports.countStaticMethods = exports.countInstanceMethods = exports.convertArrayToString = exports.saveToSessionStorage = exports.saveToLocalStorage = exports.removeFromSessionStorage = void 0;
|
|
8
|
+
exports.isValidURL = exports.isValidEmail = exports.isUUID = exports.isURL = 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 = void 0;
|
|
9
9
|
// ! String Utilities
|
|
10
10
|
var basics_1 = require("./string/basics");
|
|
11
11
|
Object.defineProperty(exports, "capitalizeString", { enumerable: true, get: function () { return basics_1.capitalizeString; } });
|
|
@@ -39,20 +39,38 @@ Object.defineProperty(exports, "getLevenshteinDistance", { enumerable: true, get
|
|
|
39
39
|
Object.defineProperty(exports, "levenshteinDistance", { enumerable: true, get: function () { return utilities_1.getLevenshteinDistance; } });
|
|
40
40
|
// ! Number Utilities
|
|
41
41
|
var basics_2 = require("./number/basics");
|
|
42
|
+
Object.defineProperty(exports, "calculateAverage", { enumerable: true, get: function () { return basics_2.getAverage; } });
|
|
42
43
|
Object.defineProperty(exports, "calculateGCD", { enumerable: true, get: function () { return basics_2.calculateHCF; } });
|
|
43
44
|
Object.defineProperty(exports, "calculateHCF", { enumerable: true, get: function () { return basics_2.calculateHCF; } });
|
|
44
45
|
Object.defineProperty(exports, "calculateLCD", { enumerable: true, get: function () { return basics_2.calculateLCM; } });
|
|
45
46
|
Object.defineProperty(exports, "calculateLCM", { enumerable: true, get: function () { return basics_2.calculateLCM; } });
|
|
47
|
+
Object.defineProperty(exports, "calculateOriginalFromPercentage", { enumerable: true, get: function () { return basics_2.getOriginalFromPercentage; } });
|
|
48
|
+
Object.defineProperty(exports, "calculatePercentage", { enumerable: true, get: function () { return basics_2.getPercentage; } });
|
|
46
49
|
Object.defineProperty(exports, "convertToDecimal", { enumerable: true, get: function () { return basics_2.convertToDecimal; } });
|
|
47
|
-
Object.defineProperty(exports, "
|
|
48
|
-
Object.defineProperty(exports, "
|
|
49
|
-
Object.defineProperty(exports, "
|
|
50
|
+
Object.defineProperty(exports, "getAverage", { enumerable: true, get: function () { return basics_2.getAverage; } });
|
|
51
|
+
Object.defineProperty(exports, "getAverageOfNumbers", { enumerable: true, get: function () { return basics_2.getAverage; } });
|
|
52
|
+
Object.defineProperty(exports, "getOriginalNumberFromPercentage", { enumerable: true, get: function () { return basics_2.getOriginalFromPercentage; } });
|
|
53
|
+
Object.defineProperty(exports, "getPercentage", { enumerable: true, get: function () { return basics_2.getPercentage; } });
|
|
54
|
+
Object.defineProperty(exports, "getPercentageOfWhat", { enumerable: true, get: function () { return basics_2.getOriginalFromPercentage; } });
|
|
55
|
+
Object.defineProperty(exports, "getPercentageResult", { enumerable: true, get: function () { return basics_2.getValueFromPercentage; } });
|
|
50
56
|
Object.defineProperty(exports, "getRandomNumber", { enumerable: true, get: function () { return basics_2.getRandomNumber; } });
|
|
51
57
|
Object.defineProperty(exports, "getSumOfNumbers", { enumerable: true, get: function () { return basics_2.sumNumbers; } });
|
|
58
|
+
Object.defineProperty(exports, "getValueFromPercentage", { enumerable: true, get: function () { return basics_2.getValueFromPercentage; } });
|
|
59
|
+
Object.defineProperty(exports, "percentageOfWhat", { enumerable: true, get: function () { return basics_2.getOriginalFromPercentage; } });
|
|
52
60
|
Object.defineProperty(exports, "reverseNumber", { enumerable: true, get: function () { return basics_2.reverseNumber; } });
|
|
53
61
|
Object.defineProperty(exports, "sumDigits", { enumerable: true, get: function () { return basics_2.sumDigits; } });
|
|
54
62
|
Object.defineProperty(exports, "sumNumbers", { enumerable: true, get: function () { return basics_2.sumNumbers; } });
|
|
55
63
|
Object.defineProperty(exports, "sumOfNumbers", { enumerable: true, get: function () { return basics_2.sumNumbers; } });
|
|
64
|
+
var fibonacci_1 = require("./number/fibonacci");
|
|
65
|
+
Object.defineProperty(exports, "fibonacciGenerator", { enumerable: true, get: function () { return fibonacci_1.fibonacciGenerator; } });
|
|
66
|
+
Object.defineProperty(exports, "generateFibonacci", { enumerable: true, get: function () { return fibonacci_1.fibonacciGenerator; } });
|
|
67
|
+
Object.defineProperty(exports, "getFibonacci", { enumerable: true, get: function () { return fibonacci_1.getFibonacciSeries; } });
|
|
68
|
+
Object.defineProperty(exports, "getFibonacciNumbers", { enumerable: true, get: function () { return fibonacci_1.getFibonacciSeries; } });
|
|
69
|
+
Object.defineProperty(exports, "getFibonacciSeries", { enumerable: true, get: function () { return fibonacci_1.getFibonacciSeries; } });
|
|
70
|
+
Object.defineProperty(exports, "getFibonacciSeriesMemo", { enumerable: true, get: function () { return fibonacci_1.getFibonacciSeriesMemo; } });
|
|
71
|
+
Object.defineProperty(exports, "getMemoizedFibonacci", { enumerable: true, get: function () { return fibonacci_1.getFibonacciSeriesMemo; } });
|
|
72
|
+
Object.defineProperty(exports, "getMemoizedFibonacciSeries", { enumerable: true, get: function () { return fibonacci_1.getFibonacciSeriesMemo; } });
|
|
73
|
+
Object.defineProperty(exports, "getNthFibonacci", { enumerable: true, get: function () { return fibonacci_1.getNthFibonacci; } });
|
|
56
74
|
var guards_2 = require("./number/guards");
|
|
57
75
|
Object.defineProperty(exports, "isEven", { enumerable: true, get: function () { return guards_2.isEven; } });
|
|
58
76
|
Object.defineProperty(exports, "isEvenNumber", { enumerable: true, get: function () { return guards_2.isEven; } });
|
|
@@ -240,11 +258,11 @@ Object.defineProperty(exports, "convertArrayToString", { enumerable: true, get:
|
|
|
240
258
|
Object.defineProperty(exports, "countInstanceMethods", { enumerable: true, get: function () { return utils_4.countInstanceMethods; } });
|
|
241
259
|
Object.defineProperty(exports, "countStaticMethods", { enumerable: true, get: function () { return utils_4.countStaticMethods; } });
|
|
242
260
|
Object.defineProperty(exports, "debounceAction", { enumerable: true, get: function () { return utils_4.debounceAction; } });
|
|
261
|
+
Object.defineProperty(exports, "getClassDetails", { enumerable: true, get: function () { return utils_4.getClassDetails; } });
|
|
243
262
|
Object.defineProperty(exports, "getInstanceMethodNames", { enumerable: true, get: function () { return utils_4.getInstanceMethodNames; } });
|
|
244
263
|
Object.defineProperty(exports, "getInstanceMethodsCount", { enumerable: true, get: function () { return utils_4.countInstanceMethods; } });
|
|
245
264
|
Object.defineProperty(exports, "getStaticMethodNames", { enumerable: true, get: function () { return utils_4.getStaticMethodNames; } });
|
|
246
265
|
Object.defineProperty(exports, "getStaticMethodsCount", { enumerable: true, get: function () { return utils_4.countStaticMethods; } });
|
|
247
|
-
Object.defineProperty(exports, "getClassDetails", { enumerable: true, get: function () { return utils_4.getClassDetails; } });
|
|
248
266
|
Object.defineProperty(exports, "isDeepEqual", { enumerable: true, get: function () { return utils_4.isDeepEqual; } });
|
|
249
267
|
Object.defineProperty(exports, "throttleAction", { enumerable: true, get: function () { return utils_4.throttleAction; } });
|
|
250
268
|
// ! Primitive Type Guards
|
|
@@ -276,14 +294,14 @@ Object.defineProperty(exports, "isFunction", { enumerable: true, get: function (
|
|
|
276
294
|
Object.defineProperty(exports, "isJSON", { enumerable: true, get: function () { return non_primitives_1.isJSON; } });
|
|
277
295
|
Object.defineProperty(exports, "isJSONObject", { enumerable: true, get: function () { return non_primitives_1.isJSON; } });
|
|
278
296
|
Object.defineProperty(exports, "isMap", { enumerable: true, get: function () { return non_primitives_1.isMap; } });
|
|
297
|
+
Object.defineProperty(exports, "isMethod", { enumerable: true, get: function () { return non_primitives_1.isMethodDescriptor; } });
|
|
298
|
+
Object.defineProperty(exports, "isMethodDescriptor", { enumerable: true, get: function () { return non_primitives_1.isMethodDescriptor; } });
|
|
279
299
|
Object.defineProperty(exports, "isNotEmptyObject", { enumerable: true, get: function () { return non_primitives_1.isNotEmptyObject; } });
|
|
280
300
|
Object.defineProperty(exports, "isObject", { enumerable: true, get: function () { return non_primitives_1.isObject; } });
|
|
281
301
|
Object.defineProperty(exports, "isObjectEmpty", { enumerable: true, get: function () { return non_primitives_1.isEmptyObject; } });
|
|
282
302
|
Object.defineProperty(exports, "isObjectWithKeys", { enumerable: true, get: function () { return non_primitives_1.isObjectWithKeys; } });
|
|
283
303
|
Object.defineProperty(exports, "isPromise", { enumerable: true, get: function () { return non_primitives_1.isPromise; } });
|
|
284
304
|
Object.defineProperty(exports, "isRegExp", { enumerable: true, get: function () { return non_primitives_1.isRegExp; } });
|
|
285
|
-
Object.defineProperty(exports, "isMethodDescriptor", { enumerable: true, get: function () { return non_primitives_1.isMethodDescriptor; } });
|
|
286
|
-
Object.defineProperty(exports, "isMethod", { enumerable: true, get: function () { return non_primitives_1.isMethodDescriptor; } });
|
|
287
305
|
Object.defineProperty(exports, "isRegularExpression", { enumerable: true, get: function () { return non_primitives_1.isRegExp; } });
|
|
288
306
|
Object.defineProperty(exports, "isReturningPromise", { enumerable: true, get: function () { return non_primitives_1.isReturningPromise; } });
|
|
289
307
|
Object.defineProperty(exports, "isSet", { enumerable: true, get: function () { return non_primitives_1.isSet; } });
|
|
@@ -1,10 +1,13 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.calculateLCM = exports.calculateHCF = exports.convertToDecimal = exports.getRandomNumber = void 0;
|
|
4
|
-
exports.getFibonacciSeries = getFibonacciSeries;
|
|
5
4
|
exports.sumDigits = sumDigits;
|
|
6
5
|
exports.sumNumbers = sumNumbers;
|
|
7
6
|
exports.reverseNumber = reverseNumber;
|
|
7
|
+
exports.getAverage = getAverage;
|
|
8
|
+
exports.getPercentage = getPercentage;
|
|
9
|
+
exports.getValueFromPercentage = getValueFromPercentage;
|
|
10
|
+
exports.getOriginalFromPercentage = getOriginalFromPercentage;
|
|
8
11
|
const helpers_1 = require("./helpers");
|
|
9
12
|
/**
|
|
10
13
|
* * Utility to generate a random number between a given range.
|
|
@@ -70,9 +73,12 @@ exports.convertToDecimal = convertToDecimal;
|
|
|
70
73
|
* @returns The HCF/GCD of all the provided numbers.
|
|
71
74
|
*/
|
|
72
75
|
const calculateHCF = (...numbers) => {
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
+
const converted = numbers.map(Number);
|
|
77
|
+
if (converted.length === 0)
|
|
78
|
+
return 0;
|
|
79
|
+
let hcf = converted[0];
|
|
80
|
+
for (let i = 1; i < converted.length; i++) {
|
|
81
|
+
hcf = (0, helpers_1._find2NumbersHCF)(hcf, converted[i]);
|
|
76
82
|
}
|
|
77
83
|
return hcf;
|
|
78
84
|
};
|
|
@@ -84,26 +90,16 @@ exports.calculateHCF = calculateHCF;
|
|
|
84
90
|
* @returns The LCM/LCD of all the provided numbers.
|
|
85
91
|
*/
|
|
86
92
|
const calculateLCM = (...numbers) => {
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
93
|
+
const converted = numbers.map(Number);
|
|
94
|
+
if (converted.length === 0)
|
|
95
|
+
return 0;
|
|
96
|
+
let lcm = converted[0];
|
|
97
|
+
for (let i = 1; i < converted.length; i++) {
|
|
98
|
+
lcm = (0, helpers_1._find2NumbersLCM)(lcm, converted[i]);
|
|
90
99
|
}
|
|
91
100
|
return lcm;
|
|
92
101
|
};
|
|
93
102
|
exports.calculateLCM = calculateLCM;
|
|
94
|
-
/**
|
|
95
|
-
* * Generates the first `n` Fibonacci numbers.
|
|
96
|
-
*
|
|
97
|
-
* @param n The number of Fibonacci numbers to generate.
|
|
98
|
-
* @returns An array containing the first `n` Fibonacci numbers.
|
|
99
|
-
*/
|
|
100
|
-
function getFibonacciSeries(n) {
|
|
101
|
-
const series = [0, 1];
|
|
102
|
-
for (let i = 2; i < n; i++) {
|
|
103
|
-
series.push(series[i - 1] + series[i - 2]);
|
|
104
|
-
}
|
|
105
|
-
return series.slice(0, n);
|
|
106
|
-
}
|
|
107
103
|
/**
|
|
108
104
|
* * Sums up all digits of a number.
|
|
109
105
|
*
|
|
@@ -137,3 +133,73 @@ function reverseNumber(num) {
|
|
|
137
133
|
const reversed = parseInt(Math.abs(Number(num)).toString().split('').reverse().join(''), 10);
|
|
138
134
|
return Number(num) < 0 ? -reversed : reversed;
|
|
139
135
|
}
|
|
136
|
+
/**
|
|
137
|
+
* * Calculates the average of a set of numbers.
|
|
138
|
+
*
|
|
139
|
+
* @param numbers - A list of numbers for which to calculate the average.
|
|
140
|
+
* @returns The average of the provided numbers. Returns `NaN` if no numbers are provided or if any invalid values are encountered.
|
|
141
|
+
*/
|
|
142
|
+
function getAverage(...numbers) {
|
|
143
|
+
const cNumbers = numbers.map(Number);
|
|
144
|
+
// Edge case: check if the input is an empty array or contains invalid values
|
|
145
|
+
if (cNumbers.length === 0) {
|
|
146
|
+
return NaN; // Return NaN if no numbers are provided
|
|
147
|
+
}
|
|
148
|
+
// Validate each number in the array
|
|
149
|
+
const validNumbers = cNumbers.filter((num) => typeof num === 'number' && !isNaN(num));
|
|
150
|
+
// Edge case: check if the valid numbers array is empty after filtering
|
|
151
|
+
if (validNumbers.length === 0) {
|
|
152
|
+
return NaN; // Return NaN if no valid numbers are found
|
|
153
|
+
}
|
|
154
|
+
// Calculate the sum of the valid numbers
|
|
155
|
+
const sum = validNumbers.reduce((acc, curr) => acc + curr, 0);
|
|
156
|
+
// Return the average
|
|
157
|
+
return sum / validNumbers.length;
|
|
158
|
+
}
|
|
159
|
+
/**
|
|
160
|
+
* * Calculates the percentage of a number based on a given part and total.
|
|
161
|
+
*
|
|
162
|
+
* @param part - The part of the total value.
|
|
163
|
+
* @param total - The total value.
|
|
164
|
+
* @returns The percentage of the part in relation to the total, rounded to two decimal places.
|
|
165
|
+
* Returns `NaN` if the total is zero or invalid.
|
|
166
|
+
*/
|
|
167
|
+
function getPercentage(part, total) {
|
|
168
|
+
if (total === 0 || !Number.isFinite(total) || !Number.isFinite(part)) {
|
|
169
|
+
return NaN; // Prevent division by zero or invalid values
|
|
170
|
+
}
|
|
171
|
+
return (part / total) * 100;
|
|
172
|
+
}
|
|
173
|
+
/**
|
|
174
|
+
* * Calculates the number that a given percentage corresponds to based on a total value.
|
|
175
|
+
*
|
|
176
|
+
* @param percentage - The percentage of the total value.
|
|
177
|
+
* @param total - The total value.
|
|
178
|
+
* @returns The number corresponding to the given percentage of the total, rounded to two decimal places.
|
|
179
|
+
* Returns `NaN` if the total is zero or invalid.
|
|
180
|
+
*/
|
|
181
|
+
function getValueFromPercentage(percentage, total) {
|
|
182
|
+
if (total === 0 ||
|
|
183
|
+
!Number.isFinite(total) ||
|
|
184
|
+
!Number.isFinite(percentage)) {
|
|
185
|
+
return NaN; // Prevent division by zero or invalid values
|
|
186
|
+
}
|
|
187
|
+
return (percentage / 100) * total;
|
|
188
|
+
}
|
|
189
|
+
/**
|
|
190
|
+
* * Calculates the original number based on the given percentage and the corresponding value.
|
|
191
|
+
*
|
|
192
|
+
* @param percentage - The percentage value (e.g., 10 for 10%).
|
|
193
|
+
* @param percentageValue - The value corresponding to the given percentage.
|
|
194
|
+
* @returns The original number from which the percentage value is derived, or `NaN` if invalid inputs are provided.
|
|
195
|
+
*/
|
|
196
|
+
function getOriginalFromPercentage(percentage, percentageValue) {
|
|
197
|
+
if (percentage === 0 ||
|
|
198
|
+
percentageValue === 0 ||
|
|
199
|
+
!Number.isFinite(percentage) ||
|
|
200
|
+
!Number.isFinite(percentageValue)) {
|
|
201
|
+
return NaN; // Prevent division by zero or invalid values
|
|
202
|
+
}
|
|
203
|
+
const original = (percentageValue / percentage) * 100;
|
|
204
|
+
return Math.round(original * 100) / 100;
|
|
205
|
+
}
|
|
@@ -9,7 +9,8 @@ const helpers_1 = require("./helpers");
|
|
|
9
9
|
* @param number - The number to convert into words.
|
|
10
10
|
* @returns The number converted in words.
|
|
11
11
|
*/
|
|
12
|
-
function numberToWords(
|
|
12
|
+
function numberToWords(num) {
|
|
13
|
+
let number = Number(num);
|
|
13
14
|
const isNegative = number < 0;
|
|
14
15
|
if (number === 0)
|
|
15
16
|
return 'zero';
|
|
@@ -35,7 +36,8 @@ function numberToWords(number) {
|
|
|
35
36
|
* @example convertToRomanNumerals(29) → "XXIX"
|
|
36
37
|
*/
|
|
37
38
|
const convertToRomanNumerals = (num) => {
|
|
38
|
-
|
|
39
|
+
let number = Number(num);
|
|
40
|
+
if (number <= 0 || number >= 4000)
|
|
39
41
|
throw new RangeError('Number must be between 1 and 3999');
|
|
40
42
|
const romanMap = [
|
|
41
43
|
[1000, 'M'],
|
|
@@ -54,9 +56,9 @@ const convertToRomanNumerals = (num) => {
|
|
|
54
56
|
];
|
|
55
57
|
let result = '';
|
|
56
58
|
for (const [value, numeral] of romanMap) {
|
|
57
|
-
while (
|
|
59
|
+
while (number >= value) {
|
|
58
60
|
result += numeral;
|
|
59
|
-
|
|
61
|
+
number -= value;
|
|
60
62
|
}
|
|
61
63
|
}
|
|
62
64
|
return result;
|
|
@@ -0,0 +1,89 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.getFibonacciSeries = getFibonacciSeries;
|
|
4
|
+
exports.getFibonacciSeriesMemo = getFibonacciSeriesMemo;
|
|
5
|
+
exports.fibonacciGenerator = fibonacciGenerator;
|
|
6
|
+
exports.getNthFibonacci = getNthFibonacci;
|
|
7
|
+
/**
|
|
8
|
+
* * Generates the first `limit` Fibonacci numbers.
|
|
9
|
+
*
|
|
10
|
+
* @param limit The number of Fibonacci numbers to generate.
|
|
11
|
+
* @returns An array containing the first `limit` Fibonacci numbers.
|
|
12
|
+
*/
|
|
13
|
+
function getFibonacciSeries(limit) {
|
|
14
|
+
const cLimit = Number(limit);
|
|
15
|
+
if (!Number.isFinite(cLimit) || cLimit <= 0) {
|
|
16
|
+
return [];
|
|
17
|
+
}
|
|
18
|
+
if (cLimit === 1)
|
|
19
|
+
return [0];
|
|
20
|
+
const series = [0, 1];
|
|
21
|
+
for (let i = 2; i < cLimit; i++) {
|
|
22
|
+
series.push(series[i - 1] + series[i - 2]);
|
|
23
|
+
}
|
|
24
|
+
return series;
|
|
25
|
+
}
|
|
26
|
+
/**
|
|
27
|
+
* * Generates the first `limit` Fibonacci numbers using recursion with memoization.
|
|
28
|
+
*
|
|
29
|
+
* @param limit - The number of Fibonacci numbers to generate.
|
|
30
|
+
* @returns An array containing the first `limit` Fibonacci numbers.
|
|
31
|
+
*/
|
|
32
|
+
function getFibonacciSeriesMemo(limit) {
|
|
33
|
+
const cLimit = Number(limit);
|
|
34
|
+
if (!Number.isFinite(cLimit) || cLimit <= 0)
|
|
35
|
+
return [];
|
|
36
|
+
if (cLimit === 1)
|
|
37
|
+
return [0];
|
|
38
|
+
const memo = new Map([
|
|
39
|
+
[0, 0],
|
|
40
|
+
[1, 1],
|
|
41
|
+
]);
|
|
42
|
+
const fib = (n) => {
|
|
43
|
+
if (memo.has(n))
|
|
44
|
+
return memo.get(n);
|
|
45
|
+
const val = fib(n - 1) + fib(n - 2);
|
|
46
|
+
memo.set(n, val);
|
|
47
|
+
return val;
|
|
48
|
+
};
|
|
49
|
+
return Array.from({ length: cLimit }, (_, i) => fib(i));
|
|
50
|
+
}
|
|
51
|
+
/**
|
|
52
|
+
* * Generator function for Fibonacci sequence up to a given limit.
|
|
53
|
+
*
|
|
54
|
+
* @param limit - Number of Fibonacci numbers to generate.
|
|
55
|
+
* @param onYield - Optional callback triggered on each yield with the current value and index.
|
|
56
|
+
* @returns A generator yielding Fibonacci numbers one by one.
|
|
57
|
+
*/
|
|
58
|
+
function* fibonacciGenerator(limit, onYield) {
|
|
59
|
+
const cLimit = Number(limit);
|
|
60
|
+
if (!Number.isFinite(cLimit) || cLimit < 0)
|
|
61
|
+
return;
|
|
62
|
+
let a = 0;
|
|
63
|
+
let b = 1;
|
|
64
|
+
for (let i = 0; i < cLimit; i++) {
|
|
65
|
+
onYield?.(a, i);
|
|
66
|
+
yield a;
|
|
67
|
+
[a, b] = [b, a + b];
|
|
68
|
+
}
|
|
69
|
+
}
|
|
70
|
+
/**
|
|
71
|
+
* * Calculates the `n`-th Fibonacci number using optimized space.
|
|
72
|
+
*
|
|
73
|
+
* @param index - The index (0-based) of the Fibonacci number.
|
|
74
|
+
* @returns The index=`n`-th Fibonacci number.
|
|
75
|
+
*/
|
|
76
|
+
function getNthFibonacci(index) {
|
|
77
|
+
const n = Number(index);
|
|
78
|
+
if (!Number.isFinite(n) || n < 0)
|
|
79
|
+
return NaN;
|
|
80
|
+
if (n === 0)
|
|
81
|
+
return 0;
|
|
82
|
+
if (n === 1)
|
|
83
|
+
return 1;
|
|
84
|
+
let a = 0, b = 1;
|
|
85
|
+
for (let i = 2; i <= n; i++) {
|
|
86
|
+
[a, b] = [b, a + b];
|
|
87
|
+
}
|
|
88
|
+
return b;
|
|
89
|
+
}
|
|
@@ -10,7 +10,7 @@ const constants_1 = require("./constants");
|
|
|
10
10
|
* @example roundToNearest(27, 5) → 25
|
|
11
11
|
*/
|
|
12
12
|
const roundToNearest = (value, interval = 5) => {
|
|
13
|
-
return Math.round(value / interval) * interval;
|
|
13
|
+
return Math.round(Number(value) / interval) * interval;
|
|
14
14
|
};
|
|
15
15
|
exports.roundToNearest = roundToNearest;
|
|
16
16
|
/**
|
|
@@ -53,7 +53,7 @@ exports.clampNumber = clampNumber;
|
|
|
53
53
|
* @example randomFloat(1.5, 3.5) → 2.84623
|
|
54
54
|
*/
|
|
55
55
|
const getRandomFloat = (min, max) => {
|
|
56
|
-
return Math.random() * (max - min) + min;
|
|
56
|
+
return Math.random() * (Number(max) - Number(min)) + Number(min);
|
|
57
57
|
};
|
|
58
58
|
exports.getRandomFloat = getRandomFloat;
|
|
59
59
|
/**
|
|
@@ -62,13 +62,13 @@ exports.getRandomFloat = getRandomFloat;
|
|
|
62
62
|
* If the `withNumber` parameter is `true`, the function returns the number along with its ordinal suffix (e.g., "1st").
|
|
63
63
|
* Otherwise, it returns only the ordinal suffix (e.g., "st").
|
|
64
64
|
*
|
|
65
|
-
* @param
|
|
65
|
+
* @param num - The number or number string to get the ordinal suffix for.
|
|
66
66
|
* @param withNumber - Whether to include the number along with its ordinal suffix (defaults to `true`).
|
|
67
67
|
* @returns The appropriate ordinal suffix, optionally with the number (e.g., '1st' or 'st`, '2nd' or 'nd' and so on.).
|
|
68
68
|
*/
|
|
69
|
-
const getOrdinal = (
|
|
70
|
-
const remainder10 = Number(
|
|
71
|
-
const remainder100 = Number(
|
|
69
|
+
const getOrdinal = (num, withNumber = true) => {
|
|
70
|
+
const remainder10 = Number(num) % 10;
|
|
71
|
+
const remainder100 = Number(num) % 100;
|
|
72
72
|
let suffix;
|
|
73
73
|
if (remainder10 === 1 && remainder100 !== 11) {
|
|
74
74
|
suffix = 'st';
|
|
@@ -82,6 +82,6 @@ const getOrdinal = (n, withNumber = true) => {
|
|
|
82
82
|
else {
|
|
83
83
|
suffix = 'th';
|
|
84
84
|
}
|
|
85
|
-
return withNumber ? String(
|
|
85
|
+
return withNumber ? String(num).concat(suffix) : suffix;
|
|
86
86
|
};
|
|
87
87
|
exports.getOrdinal = getOrdinal;
|
|
@@ -620,9 +620,9 @@ export declare class Chronos {
|
|
|
620
620
|
* * Rounds the current date-time to the nearest specified unit and interval.
|
|
621
621
|
*
|
|
622
622
|
* @param unit - The unit to round (`year`, `month`, `week`, `day`, `hour`, `minute`, `second`, `millisecond`).
|
|
623
|
-
*
|
|
623
|
+
*
|
|
624
624
|
* @param nearest - The interval to round to. Defaults to `1`.
|
|
625
|
-
* @returns A new `Chronos` instance with the rounded value. For wrong unit returns current instance.
|
|
625
|
+
* @returns A new `Chronos` instance with the rounded value. For wrong unit returns current instance. Rounded *Month and Week are 0 based.*
|
|
626
626
|
*/
|
|
627
627
|
round(unit: TimeUnit, nearest?: number): Chronos;
|
|
628
628
|
/**
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Chronos.d.ts","sourceRoot":"","sources":["../../../src/date/Chronos.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,iBAAiB,CAAC;AAIlD,OAAO,EAIN,MAAM,EAKN,MAAM,aAAa,CAAC;AAErB,OAAO,KAAK,EAEX,YAAY,EACZ,cAAc,EACd,aAAa,EACb,OAAO,EACP,aAAa,EACb,aAAa,EACb,OAAO,EACP,YAAY,EACZ,QAAQ,EACR,QAAQ,EACR,SAAS,EACT,UAAU,EACV,MAAM,SAAS,CAAC;AAGjB;;;;;;;;;;;;;;;;;;;;GAoBG;AACH,qBAAa,OAAO;;IAGnB,CAAC,MAAM,CAAC,CAAC,EAAE,cAAc,GAAG,MAAM,CAAC;IAEnC;;;;;;OAMG;;IAGH;;;;;;OAMG;gBACS,KAAK,EAAE,MAAM;IAEzB;;;;;;OAMG;gBACS,KAAK,EAAE,MAAM;IAEzB;;;;;;OAMG;gBACS,KAAK,EAAE,IAAI;IAEvB;;;;;;OAMG;gBACS,KAAK,EAAE,OAAO;IAE1B;;;;;;;;;;;;OAYG;gBAEF,IAAI,EAAE,MAAM,EACZ,KAAK,EAAE,MAAM,EACb,IAAI,CAAC,EAAE,MAAM,EACb,KAAK,CAAC,EAAE,MAAM,EACd,OAAO,CAAC,EAAE,MAAM,EAChB,OAAO,CAAC,EAAE,MAAM,EAChB,EAAE,CAAC,EAAE,MAAM;IAGZ;;;;;;;;;;OAUG;gBACS,KA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;IAQ1B;;;;OAIG;IACH,MAAM,CAAC,GAAG,IAAI,MAAM;IAIpB;;;OAGG;IACH,MAAM,CAAC,GAAG,CAAC,QAAQ,EAAE,YAAY,GAAG,OAAO;IAM3C;;;OAGG;IACH,MAAM,CAAC,GAAG,CAAC,GAAG,KAAK,EAAE,YAAY,EAAE,GAAG,OAAO;IAM7C;;;OAGG;IACH,MAAM,CAAC,GAAG,CAAC,GAAG,KAAK,EAAE,YAAY,EAAE,GAAG,OAAO;IAM7C;;;;;;;;;;;;;;OAcG;IACH,MAAM,CAAC,UAAU,CAAC,IAAI,EAAE,YAAY,GAAG,OAAO;IAgB9C;;;;;;OAMG;IACH,MAAM,CAAC,WAAW,CAAC,KAAK,EAAE,OAAO,GAAG,KAAK,IAAI,IAAI;IAIjD;;;;;;OAMG;IACH,MAAM,CAAC,YAAY,CAAC,KAAK,EAAE,OAAO,GAAG,KAAK,IAAI,MAAM;IAIpD;;;;;OAKG;IACH,MAAM,CAAC,cAAc,CAAC,KAAK,EAAE,OAAO,GAAG,KAAK,IAAI,OAAO;CAGvD"}
|
package/dist/dts/index.d.ts
CHANGED
|
@@ -3,7 +3,8 @@ export { generateAnagrams } from './string/anagram';
|
|
|
3
3
|
export { isCamelCase, isEmojiOnly, isKebabCase, isPalindrome, isPascalCase, isSnakeCase, } from './string/guards';
|
|
4
4
|
export { convertStringCase, extractEmails, extractURLs, formatUnitWithPlural as formatNumberWithPluralUnit, formatUnitWithPlural, formatUnitWithPlural as formatWithPlural, maskString, normalizeString, replaceAllInString, reverseString, slugifyString, } from './string/convert';
|
|
5
5
|
export { extractNumbersFromString, getLevenshteinDistance, getLevenshteinDistance as levenshteinDistance, } from './string/utilities';
|
|
6
|
-
export { calculateHCF as calculateGCD, calculateHCF, calculateLCM as calculateLCD, calculateLCM, convertToDecimal,
|
|
6
|
+
export { getAverage as calculateAverage, calculateHCF as calculateGCD, calculateHCF, calculateLCM as calculateLCD, calculateLCM, getOriginalFromPercentage as calculateOriginalFromPercentage, getPercentage as calculatePercentage, convertToDecimal, getAverage, getAverage as getAverageOfNumbers, getOriginalFromPercentage as getOriginalNumberFromPercentage, getPercentage, getOriginalFromPercentage as getPercentageOfWhat, getValueFromPercentage as getPercentageResult, getRandomNumber, sumNumbers as getSumOfNumbers, getValueFromPercentage, getOriginalFromPercentage as percentageOfWhat, reverseNumber, sumDigits, sumNumbers, sumNumbers as sumOfNumbers, } from './number/basics';
|
|
7
|
+
export { fibonacciGenerator, fibonacciGenerator as generateFibonacci, getFibonacciSeries as getFibonacci, getFibonacciSeries as getFibonacciNumbers, getFibonacciSeries, getFibonacciSeriesMemo, getFibonacciSeriesMemo as getMemoizedFibonacci, getFibonacciSeriesMemo as getMemoizedFibonacciSeries, getNthFibonacci, } from './number/fibonacci';
|
|
7
8
|
export { isEven, isEven as isEvenNumber, isFibonacci, isMultiple, isOdd, isOdd as isOddNumber, isFibonacci as isParOfFibonacci, isFibonacci as isParOfFibonacciSeries, isPerfectSquare, } from './number/guards';
|
|
8
9
|
export { numberToWords as convertNumberToWords, convertToRomanNumerals, numberToWords, } from './number/convert';
|
|
9
10
|
export { findPrimeNumbers, findPrimeNumbers as getPrimeNumbers, isPrime, isPrime as isPrimeNumber, } from './number/prime';
|
|
@@ -32,8 +33,8 @@ export { convertObjectValues, pickFields, pickObjectFieldsByCondition as pickFie
|
|
|
32
33
|
export { generateQueryParams as createQueryParams, generateQueryParams as formatQueryParams, generateQueryParams, getQueryParams, updateQueryParam, } from './dom/query';
|
|
33
34
|
export { copyToClipboard, smoothScrollTo, toggleFullScreen } from './dom/utils';
|
|
34
35
|
export { getFromLocalStorage, getFromSessionStorage, removeFromLocalStorage, removeFromSessionStorage, saveToLocalStorage, saveToSessionStorage, } from './dom/storage';
|
|
35
|
-
export { convertArrayToString, countInstanceMethods, countStaticMethods, debounceAction, getInstanceMethodNames, countInstanceMethods as getInstanceMethodsCount, getStaticMethodNames, countStaticMethods as getStaticMethodsCount,
|
|
36
|
+
export { convertArrayToString, countInstanceMethods, countStaticMethods, debounceAction, getClassDetails, getInstanceMethodNames, countInstanceMethods as getInstanceMethodsCount, getStaticMethodNames, countStaticMethods as getStaticMethodsCount, isDeepEqual, throttleAction, } from './utils';
|
|
36
37
|
export { isBoolean, isFalsy, isInteger, isNonEmptyString, isNull, isNumber, isPositiveInteger, isPrimitive, isString, isSymbol, isTruthy, isUndefined, } from './guards/primitives';
|
|
37
|
-
export { isReturningPromise as doesReturnPromise, isArray, isArrayOfType, isValidArray as isArrayWithLength, isBigInt, isDate, isEmptyObject, isEmptyObject as isEmptyObjectGuard, isError, isFunction, isJSON, isJSON as isJSONObject, isMap, isNotEmptyObject, isObject, isEmptyObject as isObjectEmpty, isObjectWithKeys, isPromise, isRegExp,
|
|
38
|
+
export { isReturningPromise as doesReturnPromise, isArray, isArrayOfType, isValidArray as isArrayWithLength, isBigInt, isDate, isEmptyObject, isEmptyObject as isEmptyObjectGuard, isError, isFunction, isJSON, isJSON as isJSONObject, isMap, isMethodDescriptor as isMethod, isMethodDescriptor, isNotEmptyObject, isObject, isEmptyObject as isObjectEmpty, isObjectWithKeys, isPromise, isRegExp, isRegExp as isRegularExpression, isReturningPromise, isSet, isValidArray, isJSON as isValidJSON, isMap as isValidMap, isNotEmptyObject as isValidObject, isSet as isValidSet, } from './guards/non-primitives';
|
|
38
39
|
export { isBase64, isBrowser, isDateString, isEmail, isEmailArray, isEnvironment, isEnvironment as isExpectedNodeENV, isIPAddress, isNode, isEnvironment as isNodeENV, isEnvironment as isNodeEnvironment, isNumericString, isPhoneNumber, isURL, isUUID, isEmail as isValidEmail, isURL as isValidURL, } from './guards/specials';
|
|
39
40
|
//# sourceMappingURL=index.d.ts.map
|
package/dist/dts/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AACA,OAAO,EACN,gBAAgB,EAChB,gBAAgB,EAChB,UAAU,EACV,cAAc,GACd,MAAM,iBAAiB,CAAC;AAEzB,OAAO,EAAE,gBAAgB,EAAE,MAAM,kBAAkB,CAAC;AAEpD,OAAO,EACN,WAAW,EACX,WAAW,EACX,WAAW,EACX,YAAY,EACZ,YAAY,EACZ,WAAW,GACX,MAAM,iBAAiB,CAAC;AAEzB,OAAO,EACN,iBAAiB,EACjB,aAAa,EACb,WAAW,EACX,oBAAoB,IAAI,0BAA0B,EAClD,oBAAoB,EACpB,oBAAoB,IAAI,gBAAgB,EACxC,UAAU,EACV,eAAe,EACf,kBAAkB,EAClB,aAAa,EACb,aAAa,GACb,MAAM,kBAAkB,CAAC;AAE1B,OAAO,EACN,wBAAwB,EACxB,sBAAsB,EACtB,sBAAsB,IAAI,mBAAmB,GAC7C,MAAM,oBAAoB,CAAC;AAG5B,OAAO,EACN,YAAY,IAAI,YAAY,EAC5B,YAAY,EACZ,YAAY,IAAI,YAAY,EAC5B,YAAY,EACZ,gBAAgB,EAChB,
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AACA,OAAO,EACN,gBAAgB,EAChB,gBAAgB,EAChB,UAAU,EACV,cAAc,GACd,MAAM,iBAAiB,CAAC;AAEzB,OAAO,EAAE,gBAAgB,EAAE,MAAM,kBAAkB,CAAC;AAEpD,OAAO,EACN,WAAW,EACX,WAAW,EACX,WAAW,EACX,YAAY,EACZ,YAAY,EACZ,WAAW,GACX,MAAM,iBAAiB,CAAC;AAEzB,OAAO,EACN,iBAAiB,EACjB,aAAa,EACb,WAAW,EACX,oBAAoB,IAAI,0BAA0B,EAClD,oBAAoB,EACpB,oBAAoB,IAAI,gBAAgB,EACxC,UAAU,EACV,eAAe,EACf,kBAAkB,EAClB,aAAa,EACb,aAAa,GACb,MAAM,kBAAkB,CAAC;AAE1B,OAAO,EACN,wBAAwB,EACxB,sBAAsB,EACtB,sBAAsB,IAAI,mBAAmB,GAC7C,MAAM,oBAAoB,CAAC;AAG5B,OAAO,EACN,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AAI,kBAAkB,EACnC,OAAO,EACP,UAAU,EACV,MAAM,EACN,MAAM,IAAI,YAAY,EACtB,KAAK,EACL,kBAAkB,IAAI,QAAQ,EAC9B,kBAAkB,EAClB,gBAAgB,EAChB,QAAQ,EACR,aAAa,IAAI,aAAa,EAC9B,gBAAgB,EAChB,SAAS,EACT,QAAQ,EACR,QAAQ,IAAI,mBAAmB,EAC/B,kBAAkB,EAClB,KAAK,EACL,YAAY,EACZ,MAAM,IAAI,WAAW,EACrB,KAAK,IAAI,UAAU,EACnB,gBAAgB,IAAI,aAAa,EACjC,KAAK,IAAI,UAAU,GACnB,MAAM,yBAAyB,CAAC;AAGjC,OAAO,EACN,QAAQ,EACR,SAAS,EACT,YAAY,EACZ,OAAO,EACP,YAAY,EACZ,aAAa,EACb,aAAa,IAAI,iBAAiB,EAClC,WAAW,EACX,MAAM,EACN,aAAa,IAAI,SAAS,EAC1B,aAAa,IAAI,iBAAiB,EAClC,eAAe,EACf,aAAa,EACb,KAAK,EACL,MAAM,EACN,OAAO,IAAI,YAAY,EACvB,KAAK,IAAI,UAAU,GACnB,MAAM,mBAAmB,CAAC"}
|
|
@@ -23,21 +23,14 @@ export declare const convertToDecimal: <T extends boolean | undefined = false>(i
|
|
|
23
23
|
* @param numbers - List of numbers to find the HCF/GCD for.
|
|
24
24
|
* @returns The HCF/GCD of all the provided numbers.
|
|
25
25
|
*/
|
|
26
|
-
export declare const calculateHCF: (...numbers:
|
|
26
|
+
export declare const calculateHCF: (...numbers: Numeric[]) => number;
|
|
27
27
|
/**
|
|
28
28
|
* * Calculates the LCM/LCD of multiple numbers.
|
|
29
29
|
*
|
|
30
30
|
* @param numbers - List of numbers to find the LCM/LCD for.
|
|
31
31
|
* @returns The LCM/LCD of all the provided numbers.
|
|
32
32
|
*/
|
|
33
|
-
export declare const calculateLCM: (...numbers:
|
|
34
|
-
/**
|
|
35
|
-
* * Generates the first `n` Fibonacci numbers.
|
|
36
|
-
*
|
|
37
|
-
* @param n The number of Fibonacci numbers to generate.
|
|
38
|
-
* @returns An array containing the first `n` Fibonacci numbers.
|
|
39
|
-
*/
|
|
40
|
-
export declare function getFibonacciSeries(n: number): number[];
|
|
33
|
+
export declare const calculateLCM: (...numbers: Numeric[]) => number;
|
|
41
34
|
/**
|
|
42
35
|
* * Sums up all digits of a number.
|
|
43
36
|
*
|
|
@@ -59,4 +52,37 @@ export declare function sumNumbers(...numbers: Numeric[]): number;
|
|
|
59
52
|
* @returns The reversed number.
|
|
60
53
|
*/
|
|
61
54
|
export declare function reverseNumber(num: Numeric): number;
|
|
55
|
+
/**
|
|
56
|
+
* * Calculates the average of a set of numbers.
|
|
57
|
+
*
|
|
58
|
+
* @param numbers - A list of numbers for which to calculate the average.
|
|
59
|
+
* @returns The average of the provided numbers. Returns `NaN` if no numbers are provided or if any invalid values are encountered.
|
|
60
|
+
*/
|
|
61
|
+
export declare function getAverage(...numbers: Numeric[]): number;
|
|
62
|
+
/**
|
|
63
|
+
* * Calculates the percentage of a number based on a given part and total.
|
|
64
|
+
*
|
|
65
|
+
* @param part - The part of the total value.
|
|
66
|
+
* @param total - The total value.
|
|
67
|
+
* @returns The percentage of the part in relation to the total, rounded to two decimal places.
|
|
68
|
+
* Returns `NaN` if the total is zero or invalid.
|
|
69
|
+
*/
|
|
70
|
+
export declare function getPercentage(part: number, total: number): number;
|
|
71
|
+
/**
|
|
72
|
+
* * Calculates the number that a given percentage corresponds to based on a total value.
|
|
73
|
+
*
|
|
74
|
+
* @param percentage - The percentage of the total value.
|
|
75
|
+
* @param total - The total value.
|
|
76
|
+
* @returns The number corresponding to the given percentage of the total, rounded to two decimal places.
|
|
77
|
+
* Returns `NaN` if the total is zero or invalid.
|
|
78
|
+
*/
|
|
79
|
+
export declare function getValueFromPercentage(percentage: number, total: number): number;
|
|
80
|
+
/**
|
|
81
|
+
* * Calculates the original number based on the given percentage and the corresponding value.
|
|
82
|
+
*
|
|
83
|
+
* @param percentage - The percentage value (e.g., 10 for 10%).
|
|
84
|
+
* @param percentageValue - The value corresponding to the given percentage.
|
|
85
|
+
* @returns The original number from which the percentage value is derived, or `NaN` if invalid inputs are provided.
|
|
86
|
+
*/
|
|
87
|
+
export declare function getOriginalFromPercentage(percentage: number, percentageValue: number): number;
|
|
62
88
|
//# sourceMappingURL=basics.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"basics.d.ts","sourceRoot":"","sources":["../../../src/number/basics.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,UAAU,CAAC;AAExC,OAAO,KAAK,EACX,gBAAgB,EAChB,cAAc,EACd,mBAAmB,EACnB,MAAM,SAAS,CAAC;AAEjB;;;;;;;GAOG;AACH,eAAO,MAAM,eAAe,aAAc,mBAAmB,KAAG,MA+C/D,CAAC;AAEF;;;;;;GAMG;AACH,eAAO,MAAM,gBAAgB,GAAI,CAAC,SAAS,OAAO,GAAG,SAAS,iBACtD,OAAO,YACJ,cAAc,CAAC,CAAC,CAAC,KACzB,gBAAgB,CAAC,CAAC,CAQpB,CAAC;AAEF;;;;;GAKG;AACH,eAAO,MAAM,YAAY,eAAgB,
|
|
1
|
+
{"version":3,"file":"basics.d.ts","sourceRoot":"","sources":["../../../src/number/basics.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,UAAU,CAAC;AAExC,OAAO,KAAK,EACX,gBAAgB,EAChB,cAAc,EACd,mBAAmB,EACnB,MAAM,SAAS,CAAC;AAEjB;;;;;;;GAOG;AACH,eAAO,MAAM,eAAe,aAAc,mBAAmB,KAAG,MA+C/D,CAAC;AAEF;;;;;;GAMG;AACH,eAAO,MAAM,gBAAgB,GAAI,CAAC,SAAS,OAAO,GAAG,SAAS,iBACtD,OAAO,YACJ,cAAc,CAAC,CAAC,CAAC,KACzB,gBAAgB,CAAC,CAAC,CAQpB,CAAC;AAEF;;;;;GAKG;AACH,eAAO,MAAM,YAAY,eAAgB,OAAO,EAAE,KAAG,MAYpD,CAAC;AAEF;;;;;GAKG;AACH,eAAO,MAAM,YAAY,eAAgB,OAAO,EAAE,KAAG,MAYpD,CAAC;AAEF;;;;;GAKG;AACH,wBAAgB,SAAS,CAAC,GAAG,EAAE,OAAO,GAAG,MAAM,CAK9C;AAED;;;;;GAKG;AACH,wBAAgB,UAAU,CAAC,GAAG,OAAO,EAAE,OAAO,EAAE,GAAG,MAAM,CAIxD;AAED;;;;;GAKG;AACH,wBAAgB,aAAa,CAAC,GAAG,EAAE,OAAO,GAAG,MAAM,CAOlD;AAED;;;;;GAKG;AACH,wBAAgB,UAAU,CAAC,GAAG,OAAO,EAAE,OAAO,EAAE,GAAG,MAAM,CAsBxD;AAED;;;;;;;GAOG;AACH,wBAAgB,aAAa,CAAC,IAAI,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,GAAG,MAAM,CAKjE;AAED;;;;;;;GAOG;AACH,wBAAgB,sBAAsB,CACrC,UAAU,EAAE,MAAM,EAClB,KAAK,EAAE,MAAM,GACX,MAAM,CASR;AAED;;;;;;GAMG;AACH,wBAAgB,yBAAyB,CACxC,UAAU,EAAE,MAAM,EAClB,eAAe,EAAE,MAAM,GACrB,MAAM,CAYR"}
|
|
@@ -1,14 +1,15 @@
|
|
|
1
|
+
import type { Numeric } from '../types';
|
|
1
2
|
/**
|
|
2
3
|
* * Converts a number to words
|
|
3
4
|
* @param number - The number to convert into words.
|
|
4
5
|
* @returns The number converted in words.
|
|
5
6
|
*/
|
|
6
|
-
export declare function numberToWords(
|
|
7
|
+
export declare function numberToWords(num: Numeric): string;
|
|
7
8
|
/**
|
|
8
9
|
* * Converts a number to a Roman numeral.
|
|
9
10
|
* @param num - The number to convert.
|
|
10
11
|
* @returns The Roman numeral representation.
|
|
11
12
|
* @example convertToRomanNumerals(29) → "XXIX"
|
|
12
13
|
*/
|
|
13
|
-
export declare const convertToRomanNumerals: (num:
|
|
14
|
+
export declare const convertToRomanNumerals: (num: Numeric) => string;
|
|
14
15
|
//# sourceMappingURL=convert.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"convert.d.ts","sourceRoot":"","sources":["../../../src/number/convert.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"convert.d.ts","sourceRoot":"","sources":["../../../src/number/convert.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,UAAU,CAAC;AAIxC;;;;GAIG;AACH,wBAAgB,aAAa,CAAC,GAAG,EAAE,OAAO,GAAG,MAAM,CA4BlD;AAED;;;;;GAKG;AACH,eAAO,MAAM,sBAAsB,QAAS,OAAO,KAAG,MA8BrD,CAAC"}
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
import type { Numeric } from '../types';
|
|
2
|
+
/**
|
|
3
|
+
* * Generates the first `limit` Fibonacci numbers.
|
|
4
|
+
*
|
|
5
|
+
* @param limit The number of Fibonacci numbers to generate.
|
|
6
|
+
* @returns An array containing the first `limit` Fibonacci numbers.
|
|
7
|
+
*/
|
|
8
|
+
export declare function getFibonacciSeries(limit: Numeric): number[];
|
|
9
|
+
/**
|
|
10
|
+
* * Generates the first `limit` Fibonacci numbers using recursion with memoization.
|
|
11
|
+
*
|
|
12
|
+
* @param limit - The number of Fibonacci numbers to generate.
|
|
13
|
+
* @returns An array containing the first `limit` Fibonacci numbers.
|
|
14
|
+
*/
|
|
15
|
+
export declare function getFibonacciSeriesMemo(limit: Numeric): number[];
|
|
16
|
+
/**
|
|
17
|
+
* * Generator function for Fibonacci sequence up to a given limit.
|
|
18
|
+
*
|
|
19
|
+
* @param limit - Number of Fibonacci numbers to generate.
|
|
20
|
+
* @param onYield - Optional callback triggered on each yield with the current value and index.
|
|
21
|
+
* @returns A generator yielding Fibonacci numbers one by one.
|
|
22
|
+
*/
|
|
23
|
+
export declare function fibonacciGenerator(limit: Numeric, onYield?: (value: number, index: number) => void): Generator<number, void, void>;
|
|
24
|
+
/**
|
|
25
|
+
* * Calculates the `n`-th Fibonacci number using optimized space.
|
|
26
|
+
*
|
|
27
|
+
* @param index - The index (0-based) of the Fibonacci number.
|
|
28
|
+
* @returns The index=`n`-th Fibonacci number.
|
|
29
|
+
*/
|
|
30
|
+
export declare function getNthFibonacci(index: Numeric): number;
|
|
31
|
+
//# sourceMappingURL=fibonacci.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"fibonacci.d.ts","sourceRoot":"","sources":["../../../src/number/fibonacci.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,UAAU,CAAC;AAExC;;;;;GAKG;AACH,wBAAgB,kBAAkB,CAAC,KAAK,EAAE,OAAO,GAAG,MAAM,EAAE,CAgB3D;AAED;;;;;GAKG;AACH,wBAAgB,sBAAsB,CAAC,KAAK,EAAE,OAAO,GAAG,MAAM,EAAE,CAoB/D;AAED;;;;;;GAMG;AACH,wBAAiB,kBAAkB,CAClC,KAAK,EAAE,OAAO,EACd,OAAO,CAAC,EAAE,CAAC,KAAK,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,KAAK,IAAI,GAC9C,SAAS,CAAC,MAAM,EAAE,IAAI,EAAE,IAAI,CAAC,CAa/B;AAED;;;;;GAKG;AACH,wBAAgB,eAAe,CAAC,KAAK,EAAE,OAAO,GAAG,MAAM,CAetD"}
|
|
@@ -7,7 +7,7 @@ import type { CurrencyCode, LocaleCode } from './types';
|
|
|
7
7
|
* @returns The number rounded to the nearest interval.
|
|
8
8
|
* @example roundToNearest(27, 5) → 25
|
|
9
9
|
*/
|
|
10
|
-
export declare const roundToNearest: (value:
|
|
10
|
+
export declare const roundToNearest: (value: Numeric, interval?: number) => number;
|
|
11
11
|
/**
|
|
12
12
|
* * Formats a number as a currency string.
|
|
13
13
|
* @param value - The number to format.
|
|
@@ -18,7 +18,7 @@ export declare const roundToNearest: (value: number, interval?: number) => numbe
|
|
|
18
18
|
* @example formatCurrency(1234.56, "USD") → "$1,234.56"
|
|
19
19
|
* @example formatCurrency(1234.56, "USD", "en-US") → "$1,234.56"
|
|
20
20
|
*/
|
|
21
|
-
export declare const formatCurrency: (value:
|
|
21
|
+
export declare const formatCurrency: (value: Numeric, currency?: CurrencyCode, locale?: LocaleCode) => string;
|
|
22
22
|
/**
|
|
23
23
|
* * Clamps a number within a specified range.
|
|
24
24
|
* @param value - The number to clamp.
|
|
@@ -37,16 +37,16 @@ export declare const clampNumber: (value: number, min: number, max: number) => n
|
|
|
37
37
|
* @returns A random floating-point number between min and max.
|
|
38
38
|
* @example randomFloat(1.5, 3.5) → 2.84623
|
|
39
39
|
*/
|
|
40
|
-
export declare const getRandomFloat: (min:
|
|
40
|
+
export declare const getRandomFloat: (min: Numeric, max: Numeric) => number;
|
|
41
41
|
/**
|
|
42
42
|
* * Returns the ordinal suffix for a given number (e.g., 1 -> 'st', 2 -> 'nd', 3 -> 'rd', 4 -> 'th' etc.).
|
|
43
43
|
* @description The function handles special cases for 11, 12, and 13, which all use 'th' despite the last digit.
|
|
44
44
|
* If the `withNumber` parameter is `true`, the function returns the number along with its ordinal suffix (e.g., "1st").
|
|
45
45
|
* Otherwise, it returns only the ordinal suffix (e.g., "st").
|
|
46
46
|
*
|
|
47
|
-
* @param
|
|
47
|
+
* @param num - The number or number string to get the ordinal suffix for.
|
|
48
48
|
* @param withNumber - Whether to include the number along with its ordinal suffix (defaults to `true`).
|
|
49
49
|
* @returns The appropriate ordinal suffix, optionally with the number (e.g., '1st' or 'st`, '2nd' or 'nd' and so on.).
|
|
50
50
|
*/
|
|
51
|
-
export declare const getOrdinal: (
|
|
51
|
+
export declare const getOrdinal: (num: Numeric, withNumber?: boolean) => string;
|
|
52
52
|
//# sourceMappingURL=utilities.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"utilities.d.ts","sourceRoot":"","sources":["../../../src/number/utilities.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,UAAU,CAAC;AAExC,OAAO,KAAK,EAAE,YAAY,EAAE,UAAU,EAAE,MAAM,SAAS,CAAC;AAExD;;;;;;GAMG;AACH,eAAO,MAAM,cAAc,UAAW,
|
|
1
|
+
{"version":3,"file":"utilities.d.ts","sourceRoot":"","sources":["../../../src/number/utilities.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,UAAU,CAAC;AAExC,OAAO,KAAK,EAAE,YAAY,EAAE,UAAU,EAAE,MAAM,SAAS,CAAC;AAExD;;;;;;GAMG;AACH,eAAO,MAAM,cAAc,UAAW,OAAO,wBAAiB,MAE7D,CAAC;AAEF;;;;;;;;;GASG;AACH,eAAO,MAAM,cAAc,UACnB,OAAO,aACJ,YAAY,WACb,UAAU,KACjB,MAQF,CAAC;AAEF;;;;;;;;;GASG;AACH,eAAO,MAAM,WAAW,UAChB,MAAM,OACR,MAAM,OACN,MAAM,KACT,MAEF,CAAC;AAEF;;;;;;GAMG;AACH,eAAO,MAAM,cAAc,QAAS,OAAO,OAAO,OAAO,KAAG,MAE3D,CAAC;AAEF;;;;;;;;;GASG;AACH,eAAO,MAAM,UAAU,QAAS,OAAO,2BAAsB,MAiB5D,CAAC"}
|
package/dist/esm/date/Chronos.js
CHANGED
|
@@ -44,14 +44,12 @@ export class Chronos {
|
|
|
44
44
|
* @returns Instance of `Chronos` with all methods and properties.
|
|
45
45
|
*/
|
|
46
46
|
constructor(valueOrYear, month, date, hours, minutes, seconds, ms) {
|
|
47
|
-
let newDate;
|
|
48
47
|
if (typeof valueOrYear === 'number' && typeof month === 'number') {
|
|
49
|
-
|
|
48
|
+
this.#date = new Date(valueOrYear, month - 1, date ?? 1, hours ?? 0, minutes ?? 0, seconds ?? 0, ms ?? 0);
|
|
50
49
|
}
|
|
51
50
|
else {
|
|
52
|
-
|
|
51
|
+
this.#date = this.#toNewDate(valueOrYear);
|
|
53
52
|
}
|
|
54
|
-
this.#date = newDate;
|
|
55
53
|
this[ORIGIN] = 'root';
|
|
56
54
|
this.#offset = `UTC${this.getUTCOffset()}`;
|
|
57
55
|
}
|
|
@@ -1413,9 +1411,9 @@ export class Chronos {
|
|
|
1413
1411
|
* * Rounds the current date-time to the nearest specified unit and interval.
|
|
1414
1412
|
*
|
|
1415
1413
|
* @param unit - The unit to round (`year`, `month`, `week`, `day`, `hour`, `minute`, `second`, `millisecond`).
|
|
1416
|
-
*
|
|
1414
|
+
*
|
|
1417
1415
|
* @param nearest - The interval to round to. Defaults to `1`.
|
|
1418
|
-
* @returns A new `Chronos` instance with the rounded value. For wrong unit returns current instance.
|
|
1416
|
+
* @returns A new `Chronos` instance with the rounded value. For wrong unit returns current instance. Rounded *Month and Week are 0 based.*
|
|
1419
1417
|
*/
|
|
1420
1418
|
round(unit, nearest = 1) {
|
|
1421
1419
|
const date = new Date(this.#date);
|
package/dist/esm/index.js
CHANGED
|
@@ -5,7 +5,8 @@ export { isCamelCase, isEmojiOnly, isKebabCase, isPalindrome, isPascalCase, isSn
|
|
|
5
5
|
export { convertStringCase, extractEmails, extractURLs, formatUnitWithPlural as formatNumberWithPluralUnit, formatUnitWithPlural, formatUnitWithPlural as formatWithPlural, maskString, normalizeString, replaceAllInString, reverseString, slugifyString, } from './string/convert';
|
|
6
6
|
export { extractNumbersFromString, getLevenshteinDistance, getLevenshteinDistance as levenshteinDistance, } from './string/utilities';
|
|
7
7
|
// ! Number Utilities
|
|
8
|
-
export { calculateHCF as calculateGCD, calculateHCF, calculateLCM as calculateLCD, calculateLCM, convertToDecimal,
|
|
8
|
+
export { getAverage as calculateAverage, calculateHCF as calculateGCD, calculateHCF, calculateLCM as calculateLCD, calculateLCM, getOriginalFromPercentage as calculateOriginalFromPercentage, getPercentage as calculatePercentage, convertToDecimal, getAverage, getAverage as getAverageOfNumbers, getOriginalFromPercentage as getOriginalNumberFromPercentage, getPercentage, getOriginalFromPercentage as getPercentageOfWhat, getValueFromPercentage as getPercentageResult, getRandomNumber, sumNumbers as getSumOfNumbers, getValueFromPercentage, getOriginalFromPercentage as percentageOfWhat, reverseNumber, sumDigits, sumNumbers, sumNumbers as sumOfNumbers, } from './number/basics';
|
|
9
|
+
export { fibonacciGenerator, fibonacciGenerator as generateFibonacci, getFibonacciSeries as getFibonacci, getFibonacciSeries as getFibonacciNumbers, getFibonacciSeries, getFibonacciSeriesMemo, getFibonacciSeriesMemo as getMemoizedFibonacci, getFibonacciSeriesMemo as getMemoizedFibonacciSeries, getNthFibonacci, } from './number/fibonacci';
|
|
9
10
|
export { isEven, isEven as isEvenNumber, isFibonacci, isMultiple, isOdd, isOdd as isOddNumber, isFibonacci as isParOfFibonacci, isFibonacci as isParOfFibonacciSeries, isPerfectSquare, } from './number/guards';
|
|
10
11
|
export { numberToWords as convertNumberToWords, convertToRomanNumerals, numberToWords, } from './number/convert';
|
|
11
12
|
export { findPrimeNumbers, findPrimeNumbers as getPrimeNumbers, isPrime, isPrime as isPrimeNumber, } from './number/prime';
|
|
@@ -41,10 +42,10 @@ export { generateQueryParams as createQueryParams, generateQueryParams as format
|
|
|
41
42
|
export { copyToClipboard, smoothScrollTo, toggleFullScreen } from './dom/utils';
|
|
42
43
|
export { getFromLocalStorage, getFromSessionStorage, removeFromLocalStorage, removeFromSessionStorage, saveToLocalStorage, saveToSessionStorage, } from './dom/storage';
|
|
43
44
|
// ! Other Utilities
|
|
44
|
-
export { convertArrayToString, countInstanceMethods, countStaticMethods, debounceAction, getInstanceMethodNames, countInstanceMethods as getInstanceMethodsCount, getStaticMethodNames, countStaticMethods as getStaticMethodsCount,
|
|
45
|
+
export { convertArrayToString, countInstanceMethods, countStaticMethods, debounceAction, getClassDetails, getInstanceMethodNames, countInstanceMethods as getInstanceMethodsCount, getStaticMethodNames, countStaticMethods as getStaticMethodsCount, isDeepEqual, throttleAction, } from './utils';
|
|
45
46
|
// ! Primitive Type Guards
|
|
46
47
|
export { isBoolean, isFalsy, isInteger, isNonEmptyString, isNull, isNumber, isPositiveInteger, isPrimitive, isString, isSymbol, isTruthy, isUndefined, } from './guards/primitives';
|
|
47
48
|
// ! Non-Primitive Type Guards
|
|
48
|
-
export { isReturningPromise as doesReturnPromise, isArray, isArrayOfType, isValidArray as isArrayWithLength, isBigInt, isDate, isEmptyObject, isEmptyObject as isEmptyObjectGuard, isError, isFunction, isJSON, isJSON as isJSONObject, isMap, isNotEmptyObject, isObject, isEmptyObject as isObjectEmpty, isObjectWithKeys, isPromise, isRegExp,
|
|
49
|
+
export { isReturningPromise as doesReturnPromise, isArray, isArrayOfType, isValidArray as isArrayWithLength, isBigInt, isDate, isEmptyObject, isEmptyObject as isEmptyObjectGuard, isError, isFunction, isJSON, isJSON as isJSONObject, isMap, isMethodDescriptor as isMethod, isMethodDescriptor, isNotEmptyObject, isObject, isEmptyObject as isObjectEmpty, isObjectWithKeys, isPromise, isRegExp, isRegExp as isRegularExpression, isReturningPromise, isSet, isValidArray, isJSON as isValidJSON, isMap as isValidMap, isNotEmptyObject as isValidObject, isSet as isValidSet, } from './guards/non-primitives';
|
|
49
50
|
// ! Special Type Guards
|
|
50
51
|
export { isBase64, isBrowser, isDateString, isEmail, isEmailArray, isEnvironment, isEnvironment as isExpectedNodeENV, isIPAddress, isNode, isEnvironment as isNodeENV, isEnvironment as isNodeEnvironment, isNumericString, isPhoneNumber, isURL, isUUID, isEmail as isValidEmail, isURL as isValidURL, } from './guards/specials';
|
|
@@ -61,9 +61,12 @@ export const convertToDecimal = (input, options) => {
|
|
|
61
61
|
* @returns The HCF/GCD of all the provided numbers.
|
|
62
62
|
*/
|
|
63
63
|
export const calculateHCF = (...numbers) => {
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
64
|
+
const converted = numbers.map(Number);
|
|
65
|
+
if (converted.length === 0)
|
|
66
|
+
return 0;
|
|
67
|
+
let hcf = converted[0];
|
|
68
|
+
for (let i = 1; i < converted.length; i++) {
|
|
69
|
+
hcf = _find2NumbersHCF(hcf, converted[i]);
|
|
67
70
|
}
|
|
68
71
|
return hcf;
|
|
69
72
|
};
|
|
@@ -74,25 +77,15 @@ export const calculateHCF = (...numbers) => {
|
|
|
74
77
|
* @returns The LCM/LCD of all the provided numbers.
|
|
75
78
|
*/
|
|
76
79
|
export const calculateLCM = (...numbers) => {
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
+
const converted = numbers.map(Number);
|
|
81
|
+
if (converted.length === 0)
|
|
82
|
+
return 0;
|
|
83
|
+
let lcm = converted[0];
|
|
84
|
+
for (let i = 1; i < converted.length; i++) {
|
|
85
|
+
lcm = _find2NumbersLCM(lcm, converted[i]);
|
|
80
86
|
}
|
|
81
87
|
return lcm;
|
|
82
88
|
};
|
|
83
|
-
/**
|
|
84
|
-
* * Generates the first `n` Fibonacci numbers.
|
|
85
|
-
*
|
|
86
|
-
* @param n The number of Fibonacci numbers to generate.
|
|
87
|
-
* @returns An array containing the first `n` Fibonacci numbers.
|
|
88
|
-
*/
|
|
89
|
-
export function getFibonacciSeries(n) {
|
|
90
|
-
const series = [0, 1];
|
|
91
|
-
for (let i = 2; i < n; i++) {
|
|
92
|
-
series.push(series[i - 1] + series[i - 2]);
|
|
93
|
-
}
|
|
94
|
-
return series.slice(0, n);
|
|
95
|
-
}
|
|
96
89
|
/**
|
|
97
90
|
* * Sums up all digits of a number.
|
|
98
91
|
*
|
|
@@ -126,3 +119,73 @@ export function reverseNumber(num) {
|
|
|
126
119
|
const reversed = parseInt(Math.abs(Number(num)).toString().split('').reverse().join(''), 10);
|
|
127
120
|
return Number(num) < 0 ? -reversed : reversed;
|
|
128
121
|
}
|
|
122
|
+
/**
|
|
123
|
+
* * Calculates the average of a set of numbers.
|
|
124
|
+
*
|
|
125
|
+
* @param numbers - A list of numbers for which to calculate the average.
|
|
126
|
+
* @returns The average of the provided numbers. Returns `NaN` if no numbers are provided or if any invalid values are encountered.
|
|
127
|
+
*/
|
|
128
|
+
export function getAverage(...numbers) {
|
|
129
|
+
const cNumbers = numbers.map(Number);
|
|
130
|
+
// Edge case: check if the input is an empty array or contains invalid values
|
|
131
|
+
if (cNumbers.length === 0) {
|
|
132
|
+
return NaN; // Return NaN if no numbers are provided
|
|
133
|
+
}
|
|
134
|
+
// Validate each number in the array
|
|
135
|
+
const validNumbers = cNumbers.filter((num) => typeof num === 'number' && !isNaN(num));
|
|
136
|
+
// Edge case: check if the valid numbers array is empty after filtering
|
|
137
|
+
if (validNumbers.length === 0) {
|
|
138
|
+
return NaN; // Return NaN if no valid numbers are found
|
|
139
|
+
}
|
|
140
|
+
// Calculate the sum of the valid numbers
|
|
141
|
+
const sum = validNumbers.reduce((acc, curr) => acc + curr, 0);
|
|
142
|
+
// Return the average
|
|
143
|
+
return sum / validNumbers.length;
|
|
144
|
+
}
|
|
145
|
+
/**
|
|
146
|
+
* * Calculates the percentage of a number based on a given part and total.
|
|
147
|
+
*
|
|
148
|
+
* @param part - The part of the total value.
|
|
149
|
+
* @param total - The total value.
|
|
150
|
+
* @returns The percentage of the part in relation to the total, rounded to two decimal places.
|
|
151
|
+
* Returns `NaN` if the total is zero or invalid.
|
|
152
|
+
*/
|
|
153
|
+
export function getPercentage(part, total) {
|
|
154
|
+
if (total === 0 || !Number.isFinite(total) || !Number.isFinite(part)) {
|
|
155
|
+
return NaN; // Prevent division by zero or invalid values
|
|
156
|
+
}
|
|
157
|
+
return (part / total) * 100;
|
|
158
|
+
}
|
|
159
|
+
/**
|
|
160
|
+
* * Calculates the number that a given percentage corresponds to based on a total value.
|
|
161
|
+
*
|
|
162
|
+
* @param percentage - The percentage of the total value.
|
|
163
|
+
* @param total - The total value.
|
|
164
|
+
* @returns The number corresponding to the given percentage of the total, rounded to two decimal places.
|
|
165
|
+
* Returns `NaN` if the total is zero or invalid.
|
|
166
|
+
*/
|
|
167
|
+
export function getValueFromPercentage(percentage, total) {
|
|
168
|
+
if (total === 0 ||
|
|
169
|
+
!Number.isFinite(total) ||
|
|
170
|
+
!Number.isFinite(percentage)) {
|
|
171
|
+
return NaN; // Prevent division by zero or invalid values
|
|
172
|
+
}
|
|
173
|
+
return (percentage / 100) * total;
|
|
174
|
+
}
|
|
175
|
+
/**
|
|
176
|
+
* * Calculates the original number based on the given percentage and the corresponding value.
|
|
177
|
+
*
|
|
178
|
+
* @param percentage - The percentage value (e.g., 10 for 10%).
|
|
179
|
+
* @param percentageValue - The value corresponding to the given percentage.
|
|
180
|
+
* @returns The original number from which the percentage value is derived, or `NaN` if invalid inputs are provided.
|
|
181
|
+
*/
|
|
182
|
+
export function getOriginalFromPercentage(percentage, percentageValue) {
|
|
183
|
+
if (percentage === 0 ||
|
|
184
|
+
percentageValue === 0 ||
|
|
185
|
+
!Number.isFinite(percentage) ||
|
|
186
|
+
!Number.isFinite(percentageValue)) {
|
|
187
|
+
return NaN; // Prevent division by zero or invalid values
|
|
188
|
+
}
|
|
189
|
+
const original = (percentageValue / percentage) * 100;
|
|
190
|
+
return Math.round(original * 100) / 100;
|
|
191
|
+
}
|
|
@@ -5,7 +5,8 @@ import { _convertLessThanThousand } from './helpers';
|
|
|
5
5
|
* @param number - The number to convert into words.
|
|
6
6
|
* @returns The number converted in words.
|
|
7
7
|
*/
|
|
8
|
-
export function numberToWords(
|
|
8
|
+
export function numberToWords(num) {
|
|
9
|
+
let number = Number(num);
|
|
9
10
|
const isNegative = number < 0;
|
|
10
11
|
if (number === 0)
|
|
11
12
|
return 'zero';
|
|
@@ -31,7 +32,8 @@ export function numberToWords(number) {
|
|
|
31
32
|
* @example convertToRomanNumerals(29) → "XXIX"
|
|
32
33
|
*/
|
|
33
34
|
export const convertToRomanNumerals = (num) => {
|
|
34
|
-
|
|
35
|
+
let number = Number(num);
|
|
36
|
+
if (number <= 0 || number >= 4000)
|
|
35
37
|
throw new RangeError('Number must be between 1 and 3999');
|
|
36
38
|
const romanMap = [
|
|
37
39
|
[1000, 'M'],
|
|
@@ -50,9 +52,9 @@ export const convertToRomanNumerals = (num) => {
|
|
|
50
52
|
];
|
|
51
53
|
let result = '';
|
|
52
54
|
for (const [value, numeral] of romanMap) {
|
|
53
|
-
while (
|
|
55
|
+
while (number >= value) {
|
|
54
56
|
result += numeral;
|
|
55
|
-
|
|
57
|
+
number -= value;
|
|
56
58
|
}
|
|
57
59
|
}
|
|
58
60
|
return result;
|
|
@@ -0,0 +1,83 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* * Generates the first `limit` Fibonacci numbers.
|
|
3
|
+
*
|
|
4
|
+
* @param limit The number of Fibonacci numbers to generate.
|
|
5
|
+
* @returns An array containing the first `limit` Fibonacci numbers.
|
|
6
|
+
*/
|
|
7
|
+
export function getFibonacciSeries(limit) {
|
|
8
|
+
const cLimit = Number(limit);
|
|
9
|
+
if (!Number.isFinite(cLimit) || cLimit <= 0) {
|
|
10
|
+
return [];
|
|
11
|
+
}
|
|
12
|
+
if (cLimit === 1)
|
|
13
|
+
return [0];
|
|
14
|
+
const series = [0, 1];
|
|
15
|
+
for (let i = 2; i < cLimit; i++) {
|
|
16
|
+
series.push(series[i - 1] + series[i - 2]);
|
|
17
|
+
}
|
|
18
|
+
return series;
|
|
19
|
+
}
|
|
20
|
+
/**
|
|
21
|
+
* * Generates the first `limit` Fibonacci numbers using recursion with memoization.
|
|
22
|
+
*
|
|
23
|
+
* @param limit - The number of Fibonacci numbers to generate.
|
|
24
|
+
* @returns An array containing the first `limit` Fibonacci numbers.
|
|
25
|
+
*/
|
|
26
|
+
export function getFibonacciSeriesMemo(limit) {
|
|
27
|
+
const cLimit = Number(limit);
|
|
28
|
+
if (!Number.isFinite(cLimit) || cLimit <= 0)
|
|
29
|
+
return [];
|
|
30
|
+
if (cLimit === 1)
|
|
31
|
+
return [0];
|
|
32
|
+
const memo = new Map([
|
|
33
|
+
[0, 0],
|
|
34
|
+
[1, 1],
|
|
35
|
+
]);
|
|
36
|
+
const fib = (n) => {
|
|
37
|
+
if (memo.has(n))
|
|
38
|
+
return memo.get(n);
|
|
39
|
+
const val = fib(n - 1) + fib(n - 2);
|
|
40
|
+
memo.set(n, val);
|
|
41
|
+
return val;
|
|
42
|
+
};
|
|
43
|
+
return Array.from({ length: cLimit }, (_, i) => fib(i));
|
|
44
|
+
}
|
|
45
|
+
/**
|
|
46
|
+
* * Generator function for Fibonacci sequence up to a given limit.
|
|
47
|
+
*
|
|
48
|
+
* @param limit - Number of Fibonacci numbers to generate.
|
|
49
|
+
* @param onYield - Optional callback triggered on each yield with the current value and index.
|
|
50
|
+
* @returns A generator yielding Fibonacci numbers one by one.
|
|
51
|
+
*/
|
|
52
|
+
export function* fibonacciGenerator(limit, onYield) {
|
|
53
|
+
const cLimit = Number(limit);
|
|
54
|
+
if (!Number.isFinite(cLimit) || cLimit < 0)
|
|
55
|
+
return;
|
|
56
|
+
let a = 0;
|
|
57
|
+
let b = 1;
|
|
58
|
+
for (let i = 0; i < cLimit; i++) {
|
|
59
|
+
onYield?.(a, i);
|
|
60
|
+
yield a;
|
|
61
|
+
[a, b] = [b, a + b];
|
|
62
|
+
}
|
|
63
|
+
}
|
|
64
|
+
/**
|
|
65
|
+
* * Calculates the `n`-th Fibonacci number using optimized space.
|
|
66
|
+
*
|
|
67
|
+
* @param index - The index (0-based) of the Fibonacci number.
|
|
68
|
+
* @returns The index=`n`-th Fibonacci number.
|
|
69
|
+
*/
|
|
70
|
+
export function getNthFibonacci(index) {
|
|
71
|
+
const n = Number(index);
|
|
72
|
+
if (!Number.isFinite(n) || n < 0)
|
|
73
|
+
return NaN;
|
|
74
|
+
if (n === 0)
|
|
75
|
+
return 0;
|
|
76
|
+
if (n === 1)
|
|
77
|
+
return 1;
|
|
78
|
+
let a = 0, b = 1;
|
|
79
|
+
for (let i = 2; i <= n; i++) {
|
|
80
|
+
[a, b] = [b, a + b];
|
|
81
|
+
}
|
|
82
|
+
return b;
|
|
83
|
+
}
|
|
@@ -7,7 +7,7 @@ import { CURRENCY_LOCALES } from './constants';
|
|
|
7
7
|
* @example roundToNearest(27, 5) → 25
|
|
8
8
|
*/
|
|
9
9
|
export const roundToNearest = (value, interval = 5) => {
|
|
10
|
-
return Math.round(value / interval) * interval;
|
|
10
|
+
return Math.round(Number(value) / interval) * interval;
|
|
11
11
|
};
|
|
12
12
|
/**
|
|
13
13
|
* * Formats a number as a currency string.
|
|
@@ -47,7 +47,7 @@ export const clampNumber = (value, min, max) => {
|
|
|
47
47
|
* @example randomFloat(1.5, 3.5) → 2.84623
|
|
48
48
|
*/
|
|
49
49
|
export const getRandomFloat = (min, max) => {
|
|
50
|
-
return Math.random() * (max - min) + min;
|
|
50
|
+
return Math.random() * (Number(max) - Number(min)) + Number(min);
|
|
51
51
|
};
|
|
52
52
|
/**
|
|
53
53
|
* * Returns the ordinal suffix for a given number (e.g., 1 -> 'st', 2 -> 'nd', 3 -> 'rd', 4 -> 'th' etc.).
|
|
@@ -55,13 +55,13 @@ export const getRandomFloat = (min, max) => {
|
|
|
55
55
|
* If the `withNumber` parameter is `true`, the function returns the number along with its ordinal suffix (e.g., "1st").
|
|
56
56
|
* Otherwise, it returns only the ordinal suffix (e.g., "st").
|
|
57
57
|
*
|
|
58
|
-
* @param
|
|
58
|
+
* @param num - The number or number string to get the ordinal suffix for.
|
|
59
59
|
* @param withNumber - Whether to include the number along with its ordinal suffix (defaults to `true`).
|
|
60
60
|
* @returns The appropriate ordinal suffix, optionally with the number (e.g., '1st' or 'st`, '2nd' or 'nd' and so on.).
|
|
61
61
|
*/
|
|
62
|
-
export const getOrdinal = (
|
|
63
|
-
const remainder10 = Number(
|
|
64
|
-
const remainder100 = Number(
|
|
62
|
+
export const getOrdinal = (num, withNumber = true) => {
|
|
63
|
+
const remainder10 = Number(num) % 10;
|
|
64
|
+
const remainder100 = Number(num) % 100;
|
|
65
65
|
let suffix;
|
|
66
66
|
if (remainder10 === 1 && remainder100 !== 11) {
|
|
67
67
|
suffix = 'st';
|
|
@@ -75,5 +75,5 @@ export const getOrdinal = (n, withNumber = true) => {
|
|
|
75
75
|
else {
|
|
76
76
|
suffix = 'th';
|
|
77
77
|
}
|
|
78
|
-
return withNumber ? String(
|
|
78
|
+
return withNumber ? String(num).concat(suffix) : suffix;
|
|
79
79
|
};
|
package/package.json
CHANGED