umt 2.5.0 → 2.7.0
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/README.md +36 -0
- package/module/Array/generateNumberArray.js +13 -7
- package/module/Array/generateNumberArray.js.map +1 -1
- package/module/Array/getArraysCommon.js +21 -3
- package/module/Array/getArraysCommon.js.map +1 -1
- package/module/Array/groupBy.js +1 -1
- package/module/Array/groupBy.js.map +1 -1
- package/module/Array/index.d.ts +2 -0
- package/module/Array/index.js +2 -0
- package/module/Array/index.js.map +1 -1
- package/module/Array/ultraNumberSort.js +2 -2
- package/module/Array/ultraNumberSort.js.map +1 -1
- package/module/Array/uniqBy.d.ts +7 -0
- package/module/Array/uniqBy.js +19 -0
- package/module/Array/uniqBy.js.map +1 -0
- package/module/Array/unique.d.ts +6 -0
- package/module/Array/unique.js +9 -0
- package/module/Array/unique.js.map +1 -0
- package/module/Color/rgbaToHsla.js +1 -1
- package/module/Color/rgbaToHsla.js.map +1 -1
- package/module/Crypto/decodeBase32.d.ts +7 -0
- package/module/Crypto/decodeBase32.js +27 -0
- package/module/Crypto/decodeBase32.js.map +1 -0
- package/module/Crypto/decodeBase32ToString.d.ts +7 -0
- package/module/Crypto/decodeBase32ToString.js +11 -0
- package/module/Crypto/decodeBase32ToString.js.map +1 -0
- package/module/Crypto/decodeBase58.d.ts +7 -0
- package/module/Crypto/decodeBase58.js +34 -0
- package/module/Crypto/decodeBase58.js.map +1 -0
- package/module/Crypto/decodeBase58ToString.d.ts +7 -0
- package/module/Crypto/decodeBase58ToString.js +11 -0
- package/module/Crypto/decodeBase58ToString.js.map +1 -0
- package/module/Crypto/encodeBase32.d.ts +7 -0
- package/module/Crypto/encodeBase32.js +28 -0
- package/module/Crypto/encodeBase32.js.map +1 -0
- package/module/Crypto/encodeBase58.d.ts +7 -0
- package/module/Crypto/encodeBase58.js +29 -0
- package/module/Crypto/encodeBase58.js.map +1 -0
- package/module/Crypto/index.d.ts +6 -0
- package/module/Crypto/index.js +7 -0
- package/module/Crypto/index.js.map +1 -0
- package/module/DataStructure/index.d.ts +1 -0
- package/module/DataStructure/index.js +2 -0
- package/module/DataStructure/index.js.map +1 -0
- package/module/DataStructure/priorityQueue.d.ts +241 -0
- package/module/DataStructure/priorityQueue.js +327 -0
- package/module/DataStructure/priorityQueue.js.map +1 -0
- package/module/Date/birthday.js +14 -6
- package/module/Date/birthday.js.map +1 -1
- package/module/Date/isLeapYear.js +3 -0
- package/module/Date/isLeapYear.js.map +1 -1
- package/module/Error/index.d.ts +1 -0
- package/module/Error/index.js +1 -0
- package/module/Error/index.js.map +1 -1
- package/module/Error/retry.d.ts +37 -0
- package/module/Error/retry.js +47 -0
- package/module/Error/retry.js.map +1 -0
- package/module/IP/getIpClass.js +1 -1
- package/module/IP/getIpClass.js.map +1 -1
- package/module/IP/getNetworkAddress.js +2 -2
- package/module/IP/getNetworkAddress.js.map +1 -1
- package/module/IP/ipToBinaryString.js +2 -2
- package/module/IP/ipToBinaryString.js.map +1 -1
- package/module/IP/subnetMaskToCidr.js +1 -1
- package/module/IP/subnetMaskToCidr.js.map +1 -1
- package/module/Math/calculator/core.js +21 -13
- package/module/Math/calculator/core.js.map +1 -1
- package/module/Math/calculator/literalExpression.js +19 -7
- package/module/Math/calculator/literalExpression.js.map +1 -1
- package/module/Math/correlationCoefficient.d.ts +11 -0
- package/module/Math/correlationCoefficient.js +40 -0
- package/module/Math/correlationCoefficient.js.map +1 -0
- package/module/Math/division.js +3 -3
- package/module/Math/division.js.map +1 -1
- package/module/Math/gcd.js +26 -4
- package/module/Math/gcd.js.map +1 -1
- package/module/Math/index.d.ts +3 -0
- package/module/Math/index.js +3 -0
- package/module/Math/index.js.map +1 -1
- package/module/Math/mode.d.ts +10 -0
- package/module/Math/mode.js +31 -0
- package/module/Math/mode.js.map +1 -0
- package/module/Math/percentile.d.ts +11 -0
- package/module/Math/percentile.js +31 -0
- package/module/Math/percentile.js.map +1 -0
- package/module/Math/standardDeviation.js +4 -2
- package/module/Math/standardDeviation.js.map +1 -1
- package/module/Object/has.js +1 -2
- package/module/Object/has.js.map +1 -1
- package/module/Object/index.d.ts +4 -0
- package/module/Object/index.js +4 -0
- package/module/Object/index.js.map +1 -1
- package/module/Object/isEmpty.d.ts +6 -0
- package/module/Object/isEmpty.js +20 -0
- package/module/Object/isEmpty.js.map +1 -0
- package/module/Object/merge.d.ts +8 -0
- package/module/Object/merge.js +10 -0
- package/module/Object/merge.js.map +1 -0
- package/module/Object/mergeDeep.d.ts +8 -0
- package/module/Object/mergeDeep.js +37 -0
- package/module/Object/mergeDeep.js.map +1 -0
- package/module/Object/omit.d.ts +7 -0
- package/module/Object/omit.js +14 -0
- package/module/Object/omit.js.map +1 -0
- package/module/Object/pickDeep.d.ts +2 -2
- package/module/Object/pickDeep.js +4 -4
- package/module/Object/pickDeep.js.map +1 -1
- package/module/Simple/Date/dayOfWeekSimple.js +3 -3
- package/module/Simple/Date/dayOfWeekSimple.js.map +1 -1
- package/module/String/camelCase.d.ts +6 -0
- package/module/String/camelCase.js +12 -0
- package/module/String/camelCase.js.map +1 -0
- package/module/String/escapeHtml.d.ts +6 -0
- package/module/String/escapeHtml.js +19 -0
- package/module/String/escapeHtml.js.map +1 -0
- package/module/String/formatString/applyFormatter.d.ts +25 -0
- package/module/String/formatString/applyFormatter.js +71 -0
- package/module/String/formatString/applyFormatter.js.map +1 -0
- package/module/String/formatString/defaultFormatters.d.ts +24 -0
- package/module/String/formatString/defaultFormatters.js +59 -0
- package/module/String/formatString/defaultFormatters.js.map +1 -0
- package/module/String/formatString/detectMode.d.ts +26 -0
- package/module/String/formatString/detectMode.js +61 -0
- package/module/String/formatString/detectMode.js.map +1 -0
- package/module/String/formatString/getValue.d.ts +27 -0
- package/module/String/formatString/getValue.js +56 -0
- package/module/String/formatString/getValue.js.map +1 -0
- package/module/String/formatString/index.d.ts +91 -0
- package/module/String/formatString/index.js +38 -0
- package/module/String/formatString/index.js.map +1 -0
- package/module/String/fuzzySearch.d.ts +14 -0
- package/module/String/fuzzySearch.js +27 -0
- package/module/String/fuzzySearch.js.map +1 -0
- package/module/String/index.d.ts +9 -0
- package/module/String/index.js +9 -0
- package/module/String/index.js.map +1 -1
- package/module/String/kebabCase.d.ts +6 -0
- package/module/String/kebabCase.js +22 -0
- package/module/String/kebabCase.js.map +1 -0
- package/module/String/levenshteinDistance.d.ts +8 -0
- package/module/String/levenshteinDistance.js +38 -0
- package/module/String/levenshteinDistance.js.map +1 -0
- package/module/String/slugify.d.ts +10 -0
- package/module/String/slugify.js +21 -0
- package/module/String/slugify.js.map +1 -0
- package/module/String/stringSimilarity.d.ts +8 -0
- package/module/String/stringSimilarity.js +23 -0
- package/module/String/stringSimilarity.js.map +1 -0
- package/module/String/truncate.d.ts +12 -0
- package/module/String/truncate.js +21 -0
- package/module/String/truncate.js.map +1 -0
- package/module/String/unescapeHtml.d.ts +17 -0
- package/module/String/unescapeHtml.js +45 -0
- package/module/String/unescapeHtml.js.map +1 -0
- package/module/Validate/core/index.js +0 -1
- package/module/Validate/core/index.js.map +1 -1
- package/module/Validate/index.d.ts +1 -0
- package/module/Validate/index.js +1 -0
- package/module/Validate/index.js.map +1 -1
- package/module/Validate/isDeepEqual.d.ts +28 -0
- package/module/Validate/isDeepEqual.js +148 -0
- package/module/Validate/isDeepEqual.js.map +1 -0
- package/module/Validate/isDouble.js +1 -1
- package/module/Validate/isDouble.js.map +1 -1
- package/module/Validate/isNode.js +1 -0
- package/module/Validate/isNode.js.map +1 -1
- package/module/Validate/isNumber.js +1 -1
- package/module/Validate/isNumber.js.map +1 -1
- package/module/Validate/isValueNaN.js +1 -1
- package/module/Validate/isValueNaN.js.map +1 -1
- package/module/Validate/number/even.js +7 -1
- package/module/Validate/number/even.js.map +1 -1
- package/module/Validate/number/odd.js +7 -1
- package/module/Validate/number/odd.js.map +1 -1
- package/module/Validate/string/email.js +20 -2
- package/module/Validate/string/email.js.map +1 -1
- package/module/es5/Array/generateNumberArray.js +15 -9
- package/module/es5/Array/getArraysCommon.js +39 -4
- package/module/es5/Array/groupBy.js +1 -1
- package/module/es5/Array/index.d.ts +2 -0
- package/module/es5/Array/index.js +22 -0
- package/module/es5/Array/ultraNumberSort.js +2 -2
- package/module/es5/Array/uniqBy.d.ts +7 -0
- package/module/es5/Array/uniqBy.js +36 -0
- package/module/es5/Array/unique.d.ts +6 -0
- package/module/es5/Array/unique.js +20 -0
- package/module/es5/Color/rgbaToHsla.js +1 -1
- package/module/es5/Crypto/decodeBase32.d.ts +7 -0
- package/module/es5/Crypto/decodeBase32.js +44 -0
- package/module/es5/Crypto/decodeBase32ToString.d.ts +7 -0
- package/module/es5/Crypto/decodeBase32ToString.js +16 -0
- package/module/es5/Crypto/decodeBase58.d.ts +7 -0
- package/module/es5/Crypto/decodeBase58.js +63 -0
- package/module/es5/Crypto/decodeBase58ToString.d.ts +7 -0
- package/module/es5/Crypto/decodeBase58ToString.js +16 -0
- package/module/es5/Crypto/encodeBase32.d.ts +7 -0
- package/module/es5/Crypto/encodeBase32.js +45 -0
- package/module/es5/Crypto/encodeBase58.d.ts +7 -0
- package/module/es5/Crypto/encodeBase58.js +55 -0
- package/module/es5/Crypto/index.d.ts +6 -0
- package/module/es5/Crypto/index.js +71 -0
- package/module/es5/DataStructure/index.d.ts +1 -0
- package/module/es5/DataStructure/index.js +16 -0
- package/module/es5/DataStructure/priorityQueue.d.ts +241 -0
- package/module/es5/DataStructure/priorityQueue.js +405 -0
- package/module/es5/Date/birthday.js +17 -3
- package/module/es5/Date/isLeapYear.js +3 -0
- package/module/es5/Error/index.d.ts +1 -0
- package/module/es5/Error/index.js +11 -0
- package/module/es5/Error/retry.d.ts +37 -0
- package/module/es5/Error/retry.js +88 -0
- package/module/es5/IP/getIpClass.js +1 -1
- package/module/es5/IP/getNetworkAddress.js +2 -2
- package/module/es5/IP/ipToBinaryString.js +2 -2
- package/module/es5/IP/subnetMaskToCidr.js +1 -1
- package/module/es5/Math/calculator/core.js +17 -9
- package/module/es5/Math/calculator/literalExpression.js +19 -6
- package/module/es5/Math/correlationCoefficient.d.ts +11 -0
- package/module/es5/Math/correlationCoefficient.js +63 -0
- package/module/es5/Math/division.js +3 -3
- package/module/es5/Math/gcd.js +43 -5
- package/module/es5/Math/index.d.ts +3 -0
- package/module/es5/Math/index.js +33 -0
- package/module/es5/Math/mode.d.ts +10 -0
- package/module/es5/Math/mode.js +67 -0
- package/module/es5/Math/percentile.d.ts +11 -0
- package/module/es5/Math/percentile.js +42 -0
- package/module/es5/Math/standardDeviation.js +4 -2
- package/module/es5/Object/has.js +1 -1
- package/module/es5/Object/index.d.ts +4 -0
- package/module/es5/Object/index.js +44 -0
- package/module/es5/Object/isEmpty.d.ts +6 -0
- package/module/es5/Object/isEmpty.js +26 -0
- package/module/es5/Object/merge.d.ts +8 -0
- package/module/es5/Object/merge.js +18 -0
- package/module/es5/Object/mergeDeep.d.ts +8 -0
- package/module/es5/Object/mergeDeep.js +46 -0
- package/module/es5/Object/omit.d.ts +7 -0
- package/module/es5/Object/omit.js +29 -0
- package/module/es5/Object/pickDeep.d.ts +2 -2
- package/module/es5/Object/pickDeep.js +4 -4
- package/module/es5/Simple/Date/dayOfWeekSimple.js +3 -3
- package/module/es5/String/camelCase.d.ts +6 -0
- package/module/es5/String/camelCase.js +18 -0
- package/module/es5/String/escapeHtml.d.ts +6 -0
- package/module/es5/String/escapeHtml.js +27 -0
- package/module/es5/String/formatString/applyFormatter.d.ts +25 -0
- package/module/es5/String/formatString/applyFormatter.js +100 -0
- package/module/es5/String/formatString/defaultFormatters.d.ts +24 -0
- package/module/es5/String/formatString/defaultFormatters.js +79 -0
- package/module/es5/String/formatString/detectMode.d.ts +26 -0
- package/module/es5/String/formatString/detectMode.js +60 -0
- package/module/es5/String/formatString/getValue.d.ts +27 -0
- package/module/es5/String/formatString/getValue.js +85 -0
- package/module/es5/String/formatString/index.d.ts +91 -0
- package/module/es5/String/formatString/index.js +152 -0
- package/module/es5/String/fuzzySearch.d.ts +14 -0
- package/module/es5/String/fuzzySearch.js +50 -0
- package/module/es5/String/index.d.ts +9 -0
- package/module/es5/String/index.js +99 -0
- package/module/es5/String/kebabCase.d.ts +6 -0
- package/module/es5/String/kebabCase.js +26 -0
- package/module/es5/String/levenshteinDistance.d.ts +8 -0
- package/module/es5/String/levenshteinDistance.js +58 -0
- package/module/es5/String/slugify.d.ts +10 -0
- package/module/es5/String/slugify.js +18 -0
- package/module/es5/String/stringSimilarity.d.ts +8 -0
- package/module/es5/String/stringSimilarity.js +30 -0
- package/module/es5/String/truncate.d.ts +12 -0
- package/module/es5/String/truncate.js +27 -0
- package/module/es5/String/unescapeHtml.d.ts +17 -0
- package/module/es5/String/unescapeHtml.js +51 -0
- package/module/es5/Validate/core/index.js +0 -1
- package/module/es5/Validate/index.d.ts +1 -0
- package/module/es5/Validate/index.js +11 -0
- package/module/es5/Validate/isDeepEqual.d.ts +28 -0
- package/module/es5/Validate/isDeepEqual.js +232 -0
- package/module/es5/Validate/isDouble.js +1 -1
- package/module/es5/Validate/isNode.js +1 -0
- package/module/es5/Validate/isNumber.js +1 -1
- package/module/es5/Validate/isValueNaN.js +1 -1
- package/module/es5/Validate/number/even.js +4 -0
- package/module/es5/Validate/number/odd.js +4 -0
- package/module/es5/Validate/string/email.js +26 -1
- package/module/es5/index.d.ts +2 -0
- package/module/es5/index.js +22 -0
- package/module/es5/tsconfig.tsbuildinfo +1 -1
- package/module/es5/types/index.d.ts +1 -0
- package/module/es5/types/index.js +11 -0
- package/module/es5/types/logic/deepPartial.d.ts +37 -0
- package/module/es5/types/logic/deepPartial.js +5 -0
- package/module/es5/types/logic/deepRequired.d.ts +37 -0
- package/module/es5/types/logic/deepRequired.js +5 -0
- package/module/es5/types/logic/index.d.ts +3 -0
- package/module/es5/types/logic/index.js +33 -0
- package/module/es5/types/logic/unionToIntersection.d.ts +12 -0
- package/module/es5/types/logic/unionToIntersection.js +5 -0
- package/module/es5/types/object/index.d.ts +1 -0
- package/module/es5/types/object/index.js +11 -0
- package/module/es5/types/object/pickDeep.d.ts +13 -1
- package/module/es5/types/object/shallowObjectValue.d.ts +9 -0
- package/module/es5/types/object/shallowObjectValue.js +5 -0
- package/module/es5/types/string/formatString/formatData.d.ts +17 -0
- package/module/es5/types/string/formatString/formatData.js +5 -0
- package/module/es5/types/string/formatString/formatOptions.d.ts +21 -0
- package/module/es5/types/string/formatString/formatOptions.js +5 -0
- package/module/es5/types/string/formatString/formatString.d.ts +4 -0
- package/module/es5/types/string/formatString/formatString.js +49 -0
- package/module/es5/types/string/formatString/formatValue.d.ts +15 -0
- package/module/es5/types/string/formatString/formatValue.js +5 -0
- package/module/es5/types/string/formatString/formatter.d.ts +13 -0
- package/module/es5/types/string/formatString/formatter.js +5 -0
- package/module/es5/types/string/formatString/index.d.ts +5 -0
- package/module/es5/types/string/formatString/index.js +60 -0
- package/module/es5/types/string/index.d.ts +1 -0
- package/module/es5/types/string/index.js +16 -0
- package/module/index.d.ts +2 -0
- package/module/index.js +2 -0
- package/module/index.js.map +1 -1
- package/module/types/index.d.ts +1 -0
- package/module/types/index.js +1 -0
- package/module/types/index.js.map +1 -1
- package/module/types/logic/deepPartial.d.ts +37 -0
- package/module/types/logic/deepPartial.js +36 -0
- package/module/types/logic/deepPartial.js.map +1 -0
- package/module/types/logic/deepRequired.d.ts +37 -0
- package/module/types/logic/deepRequired.js +2 -0
- package/module/types/logic/deepRequired.js.map +1 -0
- package/module/types/logic/index.d.ts +3 -0
- package/module/types/logic/index.js +3 -0
- package/module/types/logic/index.js.map +1 -1
- package/module/types/logic/unionToIntersection.d.ts +12 -0
- package/module/types/logic/unionToIntersection.js +2 -0
- package/module/types/logic/unionToIntersection.js.map +1 -0
- package/module/types/object/index.d.ts +1 -0
- package/module/types/object/index.js +1 -0
- package/module/types/object/index.js.map +1 -1
- package/module/types/object/pickDeep.d.ts +13 -1
- package/module/types/object/shallowObjectValue.d.ts +9 -0
- package/module/types/object/shallowObjectValue.js +2 -0
- package/module/types/object/shallowObjectValue.js.map +1 -0
- package/module/types/string/formatString/formatData.d.ts +17 -0
- package/module/types/string/formatString/formatData.js +2 -0
- package/module/types/string/formatString/formatData.js.map +1 -0
- package/module/types/string/formatString/formatOptions.d.ts +21 -0
- package/module/types/string/formatString/formatOptions.js +2 -0
- package/module/types/string/formatString/formatOptions.js.map +1 -0
- package/module/types/string/formatString/formatString.d.ts +4 -0
- package/module/types/string/formatString/formatString.js +5 -0
- package/module/types/string/formatString/formatString.js.map +1 -0
- package/module/types/string/formatString/formatValue.d.ts +15 -0
- package/module/types/string/formatString/formatValue.js +2 -0
- package/module/types/string/formatString/formatValue.js.map +1 -0
- package/module/types/string/formatString/formatter.d.ts +13 -0
- package/module/types/string/formatString/formatter.js +2 -0
- package/module/types/string/formatString/formatter.js.map +1 -0
- package/module/types/string/formatString/index.d.ts +5 -0
- package/module/types/string/formatString/index.js +6 -0
- package/module/types/string/formatString/index.js.map +1 -0
- package/module/types/string/index.d.ts +1 -0
- package/module/types/string/index.js +2 -0
- package/module/types/string/index.js.map +1 -0
- package/package.json +40 -41
- package/module/String/formatString.d.ts +0 -13
- package/module/String/formatString.js +0 -18
- package/module/String/formatString.js.map +0 -1
- package/module/es5/String/formatString.d.ts +0 -13
- package/module/es5/String/formatString.js +0 -26
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
export interface RetryOptions {
|
|
2
|
+
retries?: number;
|
|
3
|
+
delay?: number;
|
|
4
|
+
shouldRetry?: (error: unknown) => boolean;
|
|
5
|
+
}
|
|
6
|
+
/**
|
|
7
|
+
* Retries a given async function with configurable retry logic
|
|
8
|
+
*
|
|
9
|
+
* @template T - The return type of the function
|
|
10
|
+
* @param function_ - The async function to retry
|
|
11
|
+
* @param options - Configuration options for retry behavior
|
|
12
|
+
* @param options.retries - Maximum number of retry attempts (default: 3)
|
|
13
|
+
* @param options.delay - Delay between retries in milliseconds (default: 1000)
|
|
14
|
+
* @param options.shouldRetry - Function to determine if an error should trigger a retry (default: always retry)
|
|
15
|
+
* @returns Promise that resolves with the function result or rejects with the final error
|
|
16
|
+
*
|
|
17
|
+
* @example
|
|
18
|
+
* ```typescript
|
|
19
|
+
* // Basic usage with default options
|
|
20
|
+
* const result = await retry(async () => {
|
|
21
|
+
* const response = await fetch('/api/data');
|
|
22
|
+
* if (!response.ok) throw new Error('Failed to fetch');
|
|
23
|
+
* return response.json();
|
|
24
|
+
* });
|
|
25
|
+
*
|
|
26
|
+
* // Custom retry configuration
|
|
27
|
+
* const result = await retry(
|
|
28
|
+
* () => riskyOperation(),
|
|
29
|
+
* {
|
|
30
|
+
* retries: 5,
|
|
31
|
+
* delay: 2000,
|
|
32
|
+
* shouldRetry: (error) => error instanceof NetworkError
|
|
33
|
+
* }
|
|
34
|
+
* );
|
|
35
|
+
* ```
|
|
36
|
+
*/
|
|
37
|
+
export declare const retry: <T>(function_: () => Promise<T>, options?: RetryOptions) => Promise<T>;
|
|
@@ -0,0 +1,88 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.retry = void 0;
|
|
7
|
+
function _regenerator() { /*! regenerator-runtime -- Copyright (c) 2014-present, Facebook, Inc. -- license (MIT): https://github.com/babel/babel/blob/main/packages/babel-helpers/LICENSE */ var e, t, r = "function" == typeof Symbol ? Symbol : {}, n = r.iterator || "@@iterator", o = r.toStringTag || "@@toStringTag"; function i(r, n, o, i) { var c = n && n.prototype instanceof Generator ? n : Generator, u = Object.create(c.prototype); return _regeneratorDefine2(u, "_invoke", function (r, n, o) { var i, c, u, f = 0, p = o || [], y = !1, G = { p: 0, n: 0, v: e, a: d, f: d.bind(e, 4), d: function d(t, r) { return i = t, c = 0, u = e, G.n = r, a; } }; function d(r, n) { for (c = r, u = n, t = 0; !y && f && !o && t < p.length; t++) { var o, i = p[t], d = G.p, l = i[2]; r > 3 ? (o = l === n) && (u = i[(c = i[4]) ? 5 : (c = 3, 3)], i[4] = i[5] = e) : i[0] <= d && ((o = r < 2 && d < i[1]) ? (c = 0, G.v = n, G.n = i[1]) : d < l && (o = r < 3 || i[0] > n || n > l) && (i[4] = r, i[5] = n, G.n = l, c = 0)); } if (o || r > 1) return a; throw y = !0, n; } return function (o, p, l) { if (f > 1) throw TypeError("Generator is already running"); for (y && 1 === p && d(p, l), c = p, u = l; (t = c < 2 ? e : u) || !y;) { i || (c ? c < 3 ? (c > 1 && (G.n = -1), d(c, u)) : G.n = u : G.v = u); try { if (f = 2, i) { if (c || (o = "next"), t = i[o]) { if (!(t = t.call(i, u))) throw TypeError("iterator result is not an object"); if (!t.done) return t; u = t.value, c < 2 && (c = 0); } else 1 === c && (t = i["return"]) && t.call(i), c < 2 && (u = TypeError("The iterator does not provide a '" + o + "' method"), c = 1); i = e; } else if ((t = (y = G.n < 0) ? u : r.call(n, G)) !== a) break; } catch (t) { i = e, c = 1, u = t; } finally { f = 1; } } return { value: t, done: y }; }; }(r, o, i), !0), u; } var a = {}; function Generator() {} function GeneratorFunction() {} function GeneratorFunctionPrototype() {} t = Object.getPrototypeOf; var c = [][n] ? t(t([][n]())) : (_regeneratorDefine2(t = {}, n, function () { return this; }), t), u = GeneratorFunctionPrototype.prototype = Generator.prototype = Object.create(c); function f(e) { return Object.setPrototypeOf ? Object.setPrototypeOf(e, GeneratorFunctionPrototype) : (e.__proto__ = GeneratorFunctionPrototype, _regeneratorDefine2(e, o, "GeneratorFunction")), e.prototype = Object.create(u), e; } return GeneratorFunction.prototype = GeneratorFunctionPrototype, _regeneratorDefine2(u, "constructor", GeneratorFunctionPrototype), _regeneratorDefine2(GeneratorFunctionPrototype, "constructor", GeneratorFunction), GeneratorFunction.displayName = "GeneratorFunction", _regeneratorDefine2(GeneratorFunctionPrototype, o, "GeneratorFunction"), _regeneratorDefine2(u), _regeneratorDefine2(u, o, "Generator"), _regeneratorDefine2(u, n, function () { return this; }), _regeneratorDefine2(u, "toString", function () { return "[object Generator]"; }), (_regenerator = function _regenerator() { return { w: i, m: f }; })(); }
|
|
8
|
+
function _regeneratorDefine2(e, r, n, t) { var i = Object.defineProperty; try { i({}, "", {}); } catch (e) { i = 0; } _regeneratorDefine2 = function _regeneratorDefine(e, r, n, t) { if (r) i ? i(e, r, { value: n, enumerable: !t, configurable: !t, writable: !t }) : e[r] = n;else { var o = function o(r, n) { _regeneratorDefine2(e, r, function (e) { return this._invoke(r, n, e); }); }; o("next", 0), o("throw", 1), o("return", 2); } }, _regeneratorDefine2(e, r, n, t); }
|
|
9
|
+
function asyncGeneratorStep(n, t, e, r, o, a, c) { try { var i = n[a](c), u = i.value; } catch (n) { return void e(n); } i.done ? t(u) : Promise.resolve(u).then(r, o); }
|
|
10
|
+
function _asyncToGenerator(n) { return function () { var t = this, e = arguments; return new Promise(function (r, o) { var a = n.apply(t, e); function _next(n) { asyncGeneratorStep(a, r, o, _next, _throw, "next", n); } function _throw(n) { asyncGeneratorStep(a, r, o, _next, _throw, "throw", n); } _next(void 0); }); }; }
|
|
11
|
+
/**
|
|
12
|
+
* Retries a given async function with configurable retry logic
|
|
13
|
+
*
|
|
14
|
+
* @template T - The return type of the function
|
|
15
|
+
* @param function_ - The async function to retry
|
|
16
|
+
* @param options - Configuration options for retry behavior
|
|
17
|
+
* @param options.retries - Maximum number of retry attempts (default: 3)
|
|
18
|
+
* @param options.delay - Delay between retries in milliseconds (default: 1000)
|
|
19
|
+
* @param options.shouldRetry - Function to determine if an error should trigger a retry (default: always retry)
|
|
20
|
+
* @returns Promise that resolves with the function result or rejects with the final error
|
|
21
|
+
*
|
|
22
|
+
* @example
|
|
23
|
+
* ```typescript
|
|
24
|
+
* // Basic usage with default options
|
|
25
|
+
* const result = await retry(async () => {
|
|
26
|
+
* const response = await fetch('/api/data');
|
|
27
|
+
* if (!response.ok) throw new Error('Failed to fetch');
|
|
28
|
+
* return response.json();
|
|
29
|
+
* });
|
|
30
|
+
*
|
|
31
|
+
* // Custom retry configuration
|
|
32
|
+
* const result = await retry(
|
|
33
|
+
* () => riskyOperation(),
|
|
34
|
+
* {
|
|
35
|
+
* retries: 5,
|
|
36
|
+
* delay: 2000,
|
|
37
|
+
* shouldRetry: (error) => error instanceof NetworkError
|
|
38
|
+
* }
|
|
39
|
+
* );
|
|
40
|
+
* ```
|
|
41
|
+
*/
|
|
42
|
+
var retry = exports.retry = function retry(function_) {
|
|
43
|
+
var options = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
|
|
44
|
+
var _options$retries = options.retries,
|
|
45
|
+
retries = _options$retries === void 0 ? 3 : _options$retries,
|
|
46
|
+
_options$delay = options.delay,
|
|
47
|
+
delay = _options$delay === void 0 ? 1000 : _options$delay,
|
|
48
|
+
_options$shouldRetry = options.shouldRetry,
|
|
49
|
+
shouldRetry = _options$shouldRetry === void 0 ? function () {
|
|
50
|
+
return true;
|
|
51
|
+
} : _options$shouldRetry;
|
|
52
|
+
var _attempt = /*#__PURE__*/function () {
|
|
53
|
+
var _ref = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee(remainingAttempts) {
|
|
54
|
+
var _t;
|
|
55
|
+
return _regenerator().w(function (_context) {
|
|
56
|
+
while (1) switch (_context.n) {
|
|
57
|
+
case 0:
|
|
58
|
+
_context.p = 0;
|
|
59
|
+
_context.n = 1;
|
|
60
|
+
return function_();
|
|
61
|
+
case 1:
|
|
62
|
+
return _context.a(2, _context.v);
|
|
63
|
+
case 2:
|
|
64
|
+
_context.p = 2;
|
|
65
|
+
_t = _context.v;
|
|
66
|
+
if (!(remainingAttempts <= 0 || !shouldRetry(_t))) {
|
|
67
|
+
_context.n = 3;
|
|
68
|
+
break;
|
|
69
|
+
}
|
|
70
|
+
throw _t;
|
|
71
|
+
case 3:
|
|
72
|
+
_context.n = 4;
|
|
73
|
+
return new Promise(function (resolve) {
|
|
74
|
+
return setTimeout(function () {
|
|
75
|
+
return resolve(_attempt(remainingAttempts - 1));
|
|
76
|
+
}, delay);
|
|
77
|
+
});
|
|
78
|
+
case 4:
|
|
79
|
+
return _context.a(2, _context.v);
|
|
80
|
+
}
|
|
81
|
+
}, _callee, null, [[0, 2]]);
|
|
82
|
+
}));
|
|
83
|
+
return function attempt(_x) {
|
|
84
|
+
return _ref.apply(this, arguments);
|
|
85
|
+
};
|
|
86
|
+
}();
|
|
87
|
+
return _attempt(retries);
|
|
88
|
+
};
|
|
@@ -19,7 +19,7 @@ var getIpClass = exports.getIpClass = function getIpClass(ip) {
|
|
|
19
19
|
if (parts.length !== 4) {
|
|
20
20
|
return "";
|
|
21
21
|
}
|
|
22
|
-
var firstOctet = Number.parseInt(parts[0]);
|
|
22
|
+
var firstOctet = Number.parseInt(parts[0], 10);
|
|
23
23
|
if (Number.isNaN(firstOctet) || firstOctet < 0 || firstOctet > 255) {
|
|
24
24
|
return "";
|
|
25
25
|
}
|
|
@@ -25,7 +25,7 @@ var getNetworkAddress = exports.getNetworkAddress = function getNetworkAddress(i
|
|
|
25
25
|
// Validate IP format
|
|
26
26
|
var ipParts = ip.split(".");
|
|
27
27
|
if (ipParts.length !== 4 || !ipParts.every(function (part) {
|
|
28
|
-
var number_ = Number.parseInt(part);
|
|
28
|
+
var number_ = Number.parseInt(part, 10);
|
|
29
29
|
return !Number.isNaN(number_) && number_ >= 0 && number_ <= 255;
|
|
30
30
|
})) {
|
|
31
31
|
throw new TypeError("Invalid IP address or subnet mask");
|
|
@@ -34,7 +34,7 @@ var getNetworkAddress = exports.getNetworkAddress = function getNetworkAddress(i
|
|
|
34
34
|
// Validate subnet mask format
|
|
35
35
|
var maskParts = subnetMask.split(".");
|
|
36
36
|
if (maskParts.length !== 4 || !maskParts.every(function (part) {
|
|
37
|
-
var number_ = Number.parseInt(part);
|
|
37
|
+
var number_ = Number.parseInt(part, 10);
|
|
38
38
|
return !Number.isNaN(number_) && number_ >= 0 && number_ <= 255;
|
|
39
39
|
})) {
|
|
40
40
|
throw new TypeError("Invalid IP address or subnet mask");
|
|
@@ -37,7 +37,7 @@ var ipToBinaryString = exports.ipToBinaryString = function ipToBinaryString(ip)
|
|
|
37
37
|
if (!octet || octet.length > 1 && octet[0] === "0") {
|
|
38
38
|
throw new Error("Invalid IP address format");
|
|
39
39
|
}
|
|
40
|
-
var number = Number.parseInt(octet);
|
|
40
|
+
var number = Number.parseInt(octet, 10);
|
|
41
41
|
if (Number.isNaN(number) || number < 0 || number > 255) {
|
|
42
42
|
throw new Error("Invalid IP address format");
|
|
43
43
|
}
|
|
@@ -50,6 +50,6 @@ var ipToBinaryString = exports.ipToBinaryString = function ipToBinaryString(ip)
|
|
|
50
50
|
_iterator.f();
|
|
51
51
|
}
|
|
52
52
|
return parts.map(function (octet) {
|
|
53
|
-
return Number.parseInt(octet).toString(2).padStart(8, "0");
|
|
53
|
+
return Number.parseInt(octet, 10).toString(2).padStart(8, "0");
|
|
54
54
|
}).join("");
|
|
55
55
|
};
|
|
@@ -24,7 +24,7 @@ var subnetMaskToCidr = exports.subnetMaskToCidr = function subnetMaskToCidr(subn
|
|
|
24
24
|
|
|
25
25
|
// Validate each octet
|
|
26
26
|
var binaryOctets = octets.map(function (octet) {
|
|
27
|
-
var number_ = Number.parseInt(octet);
|
|
27
|
+
var number_ = Number.parseInt(octet, 10);
|
|
28
28
|
if (Number.isNaN(number_) || number_ < 0 || number_ > 255) {
|
|
29
29
|
throw new Error("Invalid subnet mask format");
|
|
30
30
|
}
|
|
@@ -11,6 +11,10 @@ var _multiplication = require("@/Math/multiplication");
|
|
|
11
11
|
var _subtract = require("@/Math/subtract");
|
|
12
12
|
var _isNumber = require("@/Validate/isNumber");
|
|
13
13
|
var calculatorCore = exports.calculatorCore = function calculatorCore(expression, currencyExchange) {
|
|
14
|
+
// Handle empty string
|
|
15
|
+
if (expression === "") {
|
|
16
|
+
return "";
|
|
17
|
+
}
|
|
14
18
|
var sanitizedExpression = expression;
|
|
15
19
|
|
|
16
20
|
// Handle signs
|
|
@@ -61,6 +65,12 @@ var calculatorCore = exports.calculatorCore = function calculatorCore(expression
|
|
|
61
65
|
|
|
62
66
|
// Return result if no more calculations needed
|
|
63
67
|
else {
|
|
68
|
+
var number_ = Number(sanitizedExpression);
|
|
69
|
+
if (!Number.isNaN(number_)) {
|
|
70
|
+
// Handle floating point precision issues
|
|
71
|
+
var rounded = Math.round(number_ * 1e10) / 1e10;
|
|
72
|
+
return rounded.toString();
|
|
73
|
+
}
|
|
64
74
|
return sanitizedExpression;
|
|
65
75
|
}
|
|
66
76
|
}
|
|
@@ -86,7 +96,7 @@ var containsParentheses = function containsParentheses(expr) {
|
|
|
86
96
|
};
|
|
87
97
|
var resolveParentheses = function resolveParentheses(expr) {
|
|
88
98
|
// Logic for calculations inside parentheses
|
|
89
|
-
var match = expr.match(/\(
|
|
99
|
+
var match = expr.match(/\((-?\d+(?:\.\d+)?)([*+/-])(-?\d+(?:\.\d+)?)\)/);
|
|
90
100
|
if (match) {
|
|
91
101
|
return expr.replace(match[0], calculatorCore(match[0].replaceAll(/\(|\)/g, "")));
|
|
92
102
|
}
|
|
@@ -100,20 +110,18 @@ var containsDiv = function containsDiv(expr) {
|
|
|
100
110
|
};
|
|
101
111
|
var resolveMulExp = function resolveMulExp(expr) {
|
|
102
112
|
// Logic for multiplication and exponentiation
|
|
103
|
-
var match = expr.match(/(.*?)(
|
|
113
|
+
var match = expr.match(/(.*?)(-?\d+(?:\.\d+)?)([*^])(-?\d+(?:\.\d+)?)$/);
|
|
104
114
|
if (match) {
|
|
105
|
-
var
|
|
106
|
-
var result = operands[1] === "^" ? Math.pow(Number(operands[0]), Number(operands[2])) : (0, _multiplication.multiplication)(Number(operands[0]), Number(operands[2]));
|
|
115
|
+
var result = match[3] === "^" ? Math.pow(Number(match[2]), Number(match[4])) : (0, _multiplication.multiplication)(Number(match[2]), Number(match[4]));
|
|
107
116
|
return "".concat(match[1]).concat(result);
|
|
108
117
|
}
|
|
109
118
|
return Number.NaN.toString();
|
|
110
119
|
};
|
|
111
120
|
var resolveDiv = function resolveDiv(expr) {
|
|
112
121
|
// Logic for division
|
|
113
|
-
var match = expr.match(
|
|
122
|
+
var match = expr.match(/(-?\d+(?:\.\d+)?)\/(-?\d+(?:\.\d+)?)/);
|
|
114
123
|
if (match) {
|
|
115
|
-
var
|
|
116
|
-
var result = (0, _division.division)(Number(operands[0]), Number(operands[2]));
|
|
124
|
+
var result = (0, _division.division)(Number(match[1]), Number(match[2]));
|
|
117
125
|
return expr.replace(match[0], String(result));
|
|
118
126
|
}
|
|
119
127
|
return Number.NaN.toString();
|
|
@@ -123,9 +131,9 @@ var containsAddSub = function containsAddSub(expr) {
|
|
|
123
131
|
};
|
|
124
132
|
var resolveAddSub = function resolveAddSub(expr) {
|
|
125
133
|
// Logic for addition and subtraction
|
|
126
|
-
var match = expr.match(/(-?\d+
|
|
134
|
+
var match = expr.match(/(-?\d+(?:\.\d+)?)(\+|-)(-?\d+(?:\.\d+)?)/);
|
|
127
135
|
if (match) {
|
|
128
|
-
var result = match[
|
|
136
|
+
var result = match[2] === "+" ? (0, _addition.addition)(Number(match[1]), Number(match[3])) : (0, _subtract.subtract)(Number(match[1]), Number(match[3]));
|
|
129
137
|
return expr.replace(match[0], String(result));
|
|
130
138
|
}
|
|
131
139
|
return Number.NaN.toString();
|
|
@@ -19,18 +19,24 @@ function _arrayLikeToArray(r, a) { (null == a || a > r.length) && (a = r.length)
|
|
|
19
19
|
* @example literalExpression("3x+2=8"); // "2"
|
|
20
20
|
*/
|
|
21
21
|
var literalExpression = exports.literalExpression = function literalExpression(x) {
|
|
22
|
+
// Handle invalid equations like x=x
|
|
23
|
+
var sides = x.split("=");
|
|
24
|
+
if (sides.length === 2 && sides[0] === sides[1]) {
|
|
25
|
+
return "";
|
|
26
|
+
}
|
|
27
|
+
|
|
22
28
|
// Store numerical and variable parts of the equation
|
|
23
29
|
var numericalPart = "";
|
|
24
30
|
var variablePart = [];
|
|
25
31
|
|
|
26
32
|
// Split by equals sign and identify numerical and variable parts
|
|
27
|
-
var _iterator = _createForOfIteratorHelper(
|
|
33
|
+
var _iterator = _createForOfIteratorHelper(sides),
|
|
28
34
|
_step;
|
|
29
35
|
try {
|
|
30
36
|
for (_iterator.s(); !(_step = _iterator.n()).done;) {
|
|
31
37
|
var part = _step.value;
|
|
32
38
|
if (/[A-Za-z]+/.test(part)) {
|
|
33
|
-
variablePart = part.split(/(
|
|
39
|
+
variablePart = part.split(/([-+]?\d*[A-Za-z]+)|([-+]?\d+)/).filter(function (n) {
|
|
34
40
|
return n && n !== undefined;
|
|
35
41
|
});
|
|
36
42
|
} else {
|
|
@@ -45,11 +51,19 @@ var literalExpression = exports.literalExpression = function literalExpression(x
|
|
|
45
51
|
_iterator.f();
|
|
46
52
|
}
|
|
47
53
|
if (variablePart[1]) {
|
|
48
|
-
|
|
54
|
+
// Invert signs before calculating
|
|
55
|
+
var invertedPart = variablePart[1].replaceAll("+", "plus").replaceAll("-", "minus").replaceAll("plus", "-").replaceAll("minus", "+");
|
|
56
|
+
variablePart[1] = (0, _core.calculatorCore)(invertedPart);
|
|
49
57
|
}
|
|
50
58
|
|
|
51
59
|
// Calculate the numerical part
|
|
52
|
-
|
|
60
|
+
if (variablePart[1]) {
|
|
61
|
+
// Ensure proper sign handling when combining
|
|
62
|
+
var sign = variablePart[1].startsWith("-") ? "" : "+";
|
|
63
|
+
numericalPart = (0, _core.calculatorCore)("".concat(numericalPart).concat(sign).concat(variablePart[1]));
|
|
64
|
+
} else {
|
|
65
|
+
numericalPart = (0, _core.calculatorCore)(numericalPart);
|
|
66
|
+
}
|
|
53
67
|
|
|
54
68
|
// Split the variable part again to separate coefficient and variable
|
|
55
69
|
variablePart = variablePart[0].split(/(\d+)|([A-Za-z]+)/).filter(function (n) {
|
|
@@ -68,8 +82,7 @@ var literalExpression = exports.literalExpression = function literalExpression(x
|
|
|
68
82
|
if (/(-?)\d+\/1/.test(numericalPart)) {
|
|
69
83
|
return numericalPart.replace(/\/1/, "");
|
|
70
84
|
}
|
|
71
|
-
}
|
|
72
|
-
if (variablePart[0] !== "1") {
|
|
85
|
+
} else if (variablePart[0] !== "1") {
|
|
73
86
|
numericalPart = "".concat(numericalPart, "/").concat(variablePart[0]);
|
|
74
87
|
}
|
|
75
88
|
return numericalPart;
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Calculate the Pearson correlation coefficient between two arrays
|
|
3
|
+
* @param x - First array of numbers
|
|
4
|
+
* @param y - Second array of numbers
|
|
5
|
+
* @returns Correlation coefficient (-1 to 1)
|
|
6
|
+
* @example
|
|
7
|
+
* correlationCoefficient([1, 2, 3, 4, 5], [2, 4, 6, 8, 10]); // 1 (perfect positive correlation)
|
|
8
|
+
* correlationCoefficient([1, 2, 3, 4, 5], [5, 4, 3, 2, 1]); // -1 (perfect negative correlation)
|
|
9
|
+
* correlationCoefficient([1, 2, 3, 4, 5], [1, 1, 1, 1, 1]); // 0 (no correlation)
|
|
10
|
+
*/
|
|
11
|
+
export declare const correlationCoefficient: (x: number[], y: number[]) => number;
|
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.correlationCoefficient = void 0;
|
|
7
|
+
var _average = require("./average");
|
|
8
|
+
function _slicedToArray(r, e) { return _arrayWithHoles(r) || _iterableToArrayLimit(r, e) || _unsupportedIterableToArray(r, e) || _nonIterableRest(); }
|
|
9
|
+
function _nonIterableRest() { throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); }
|
|
10
|
+
function _iterableToArrayLimit(r, l) { var t = null == r ? null : "undefined" != typeof Symbol && r[Symbol.iterator] || r["@@iterator"]; if (null != t) { var e, n, i, u, a = [], f = !0, o = !1; try { if (i = (t = t.call(r)).next, 0 === l) { if (Object(t) !== t) return; f = !1; } else for (; !(f = (e = i.call(t)).done) && (a.push(e.value), a.length !== l); f = !0); } catch (r) { o = !0, n = r; } finally { try { if (!f && null != t["return"] && (u = t["return"](), Object(u) !== u)) return; } finally { if (o) throw n; } } return a; } }
|
|
11
|
+
function _arrayWithHoles(r) { if (Array.isArray(r)) return r; }
|
|
12
|
+
function _createForOfIteratorHelper(r, e) { var t = "undefined" != typeof Symbol && r[Symbol.iterator] || r["@@iterator"]; if (!t) { if (Array.isArray(r) || (t = _unsupportedIterableToArray(r)) || e && r && "number" == typeof r.length) { t && (r = t); var _n = 0, F = function F() {}; return { s: F, n: function n() { return _n >= r.length ? { done: !0 } : { done: !1, value: r[_n++] }; }, e: function e(r) { throw r; }, f: F }; } throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); } var o, a = !0, u = !1; return { s: function s() { t = t.call(r); }, n: function n() { var r = t.next(); return a = r.done, r; }, e: function e(r) { u = !0, o = r; }, f: function f() { try { a || null == t["return"] || t["return"](); } finally { if (u) throw o; } } }; }
|
|
13
|
+
function _unsupportedIterableToArray(r, a) { if (r) { if ("string" == typeof r) return _arrayLikeToArray(r, a); var t = {}.toString.call(r).slice(8, -1); return "Object" === t && r.constructor && (t = r.constructor.name), "Map" === t || "Set" === t ? Array.from(r) : "Arguments" === t || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(t) ? _arrayLikeToArray(r, a) : void 0; } }
|
|
14
|
+
function _arrayLikeToArray(r, a) { (null == a || a > r.length) && (a = r.length); for (var e = 0, n = Array(a); e < a; e++) n[e] = r[e]; return n; }
|
|
15
|
+
/**
|
|
16
|
+
* Calculate the Pearson correlation coefficient between two arrays
|
|
17
|
+
* @param x - First array of numbers
|
|
18
|
+
* @param y - Second array of numbers
|
|
19
|
+
* @returns Correlation coefficient (-1 to 1)
|
|
20
|
+
* @example
|
|
21
|
+
* correlationCoefficient([1, 2, 3, 4, 5], [2, 4, 6, 8, 10]); // 1 (perfect positive correlation)
|
|
22
|
+
* correlationCoefficient([1, 2, 3, 4, 5], [5, 4, 3, 2, 1]); // -1 (perfect negative correlation)
|
|
23
|
+
* correlationCoefficient([1, 2, 3, 4, 5], [1, 1, 1, 1, 1]); // 0 (no correlation)
|
|
24
|
+
*/
|
|
25
|
+
var correlationCoefficient = exports.correlationCoefficient = function correlationCoefficient(x, y) {
|
|
26
|
+
if (x.length !== y.length) {
|
|
27
|
+
throw new Error("Arrays must have the same length");
|
|
28
|
+
}
|
|
29
|
+
if (x.length === 0) {
|
|
30
|
+
return Number.NaN;
|
|
31
|
+
}
|
|
32
|
+
if (x.length === 1) {
|
|
33
|
+
return Number.NaN;
|
|
34
|
+
}
|
|
35
|
+
var meanX = (0, _average.average)(x);
|
|
36
|
+
var meanY = (0, _average.average)(y);
|
|
37
|
+
var numerator = 0;
|
|
38
|
+
var sumSquaredX = 0;
|
|
39
|
+
var sumSquaredY = 0;
|
|
40
|
+
var _iterator = _createForOfIteratorHelper(x.entries()),
|
|
41
|
+
_step;
|
|
42
|
+
try {
|
|
43
|
+
for (_iterator.s(); !(_step = _iterator.n()).done;) {
|
|
44
|
+
var _step$value = _slicedToArray(_step.value, 2),
|
|
45
|
+
index = _step$value[0],
|
|
46
|
+
element = _step$value[1];
|
|
47
|
+
var deltaX = element - meanX;
|
|
48
|
+
var deltaY = y[index] - meanY;
|
|
49
|
+
numerator += deltaX * deltaY;
|
|
50
|
+
sumSquaredX += deltaX * deltaX;
|
|
51
|
+
sumSquaredY += deltaY * deltaY;
|
|
52
|
+
}
|
|
53
|
+
} catch (err) {
|
|
54
|
+
_iterator.e(err);
|
|
55
|
+
} finally {
|
|
56
|
+
_iterator.f();
|
|
57
|
+
}
|
|
58
|
+
var denominator = Math.sqrt(sumSquaredX * sumSquaredY);
|
|
59
|
+
if (denominator === 0) {
|
|
60
|
+
return Number.NaN;
|
|
61
|
+
}
|
|
62
|
+
return numerator / denominator;
|
|
63
|
+
};
|
|
@@ -17,7 +17,7 @@ var _getDecimalLength = require("./getDecimalLength");
|
|
|
17
17
|
var division = exports.division = function division(x, y) {
|
|
18
18
|
var isFloor = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : true;
|
|
19
19
|
if (y === 0) {
|
|
20
|
-
// biome-ignore lint/suspicious/noExplicitAny:
|
|
20
|
+
// biome-ignore lint/suspicious/noExplicitAny: ignore
|
|
21
21
|
return isFloor ? Number.NaN : [Number.NaN, Number.NaN];
|
|
22
22
|
}
|
|
23
23
|
var sign = Math.sign(x) * Math.sign(y);
|
|
@@ -39,12 +39,12 @@ var division = exports.division = function division(x, y) {
|
|
|
39
39
|
var divisionResult = xInt / yInt * scalingFactor;
|
|
40
40
|
if (isFloor) {
|
|
41
41
|
// Apply sign to result
|
|
42
|
-
// biome-ignore lint/suspicious/noExplicitAny:
|
|
42
|
+
// biome-ignore lint/suspicious/noExplicitAny: ignore
|
|
43
43
|
return sign * divisionResult;
|
|
44
44
|
}
|
|
45
45
|
// When isFloor is false, calculate quotient and remainder
|
|
46
46
|
var intQuotient = Math.floor(divisionResult);
|
|
47
47
|
var remainder = xInt % yInt;
|
|
48
|
-
// biome-ignore lint/suspicious/noExplicitAny:
|
|
48
|
+
// biome-ignore lint/suspicious/noExplicitAny: ignore
|
|
49
49
|
return [sign * intQuotient, remainder];
|
|
50
50
|
};
|
package/module/es5/Math/gcd.js
CHANGED
|
@@ -4,8 +4,13 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
6
|
exports.gcd = void 0;
|
|
7
|
+
var _isDouble = require("@/Validate/isDouble");
|
|
7
8
|
function _createForOfIteratorHelper(r, e) { var t = "undefined" != typeof Symbol && r[Symbol.iterator] || r["@@iterator"]; if (!t) { if (Array.isArray(r) || (t = _unsupportedIterableToArray(r)) || e && r && "number" == typeof r.length) { t && (r = t); var _n = 0, F = function F() {}; return { s: F, n: function n() { return _n >= r.length ? { done: !0 } : { done: !1, value: r[_n++] }; }, e: function e(r) { throw r; }, f: F }; } throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); } var o, a = !0, u = !1; return { s: function s() { t = t.call(r); }, n: function n() { var r = t.next(); return a = r.done, r; }, e: function e(r) { u = !0, o = r; }, f: function f() { try { a || null == t["return"] || t["return"](); } finally { if (u) throw o; } } }; }
|
|
9
|
+
function _toConsumableArray(r) { return _arrayWithoutHoles(r) || _iterableToArray(r) || _unsupportedIterableToArray(r) || _nonIterableSpread(); }
|
|
10
|
+
function _nonIterableSpread() { throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); }
|
|
8
11
|
function _unsupportedIterableToArray(r, a) { if (r) { if ("string" == typeof r) return _arrayLikeToArray(r, a); var t = {}.toString.call(r).slice(8, -1); return "Object" === t && r.constructor && (t = r.constructor.name), "Map" === t || "Set" === t ? Array.from(r) : "Arguments" === t || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(t) ? _arrayLikeToArray(r, a) : void 0; } }
|
|
12
|
+
function _iterableToArray(r) { if ("undefined" != typeof Symbol && null != r[Symbol.iterator] || null != r["@@iterator"]) return Array.from(r); }
|
|
13
|
+
function _arrayWithoutHoles(r) { if (Array.isArray(r)) return _arrayLikeToArray(r); }
|
|
9
14
|
function _arrayLikeToArray(r, a) { (null == a || a > r.length) && (a = r.length); for (var e = 0, n = Array(a); e < a; e++) n[e] = r[e]; return n; }
|
|
10
15
|
/**
|
|
11
16
|
* Greatest Common Divisor (GCD)
|
|
@@ -15,14 +20,47 @@ function _arrayLikeToArray(r, a) { (null == a || a > r.length) && (a = r.length)
|
|
|
15
20
|
* @returns number The GCD of all input numbers
|
|
16
21
|
* @example gcd(12, 18); // 6
|
|
17
22
|
*/
|
|
18
|
-
var
|
|
19
|
-
var copyX = Math.abs(x);
|
|
20
|
-
var copyY = Math.abs(y);
|
|
23
|
+
var gcd = exports.gcd = function gcd(x, y) {
|
|
21
24
|
for (var _len = arguments.length, z = new Array(_len > 2 ? _len - 2 : 0), _key = 2; _key < _len; _key++) {
|
|
22
25
|
z[_key - 2] = arguments[_key];
|
|
23
26
|
}
|
|
27
|
+
// Handle decimal numbers by scaling them to integers
|
|
28
|
+
var allNumbers = [x, y].concat(z);
|
|
29
|
+
|
|
30
|
+
// If any number is decimal, find common decimal places and scale
|
|
31
|
+
var hasDecimals = allNumbers.some(function (number_) {
|
|
32
|
+
return (0, _isDouble.isDouble)(number_, false);
|
|
33
|
+
});
|
|
34
|
+
if (hasDecimals) {
|
|
35
|
+
// Find maximum decimal places
|
|
36
|
+
var getDecimalPlaces = function getDecimalPlaces(number_) {
|
|
37
|
+
var string_ = number_.toString();
|
|
38
|
+
return string_.includes(".") ? string_.split(".")[1].length : 0;
|
|
39
|
+
};
|
|
40
|
+
var maxDecimalPlaces = Math.max.apply(Math, _toConsumableArray(allNumbers.map(function (number_) {
|
|
41
|
+
return getDecimalPlaces(number_);
|
|
42
|
+
})));
|
|
43
|
+
var multiplier = Math.pow(10, maxDecimalPlaces);
|
|
44
|
+
|
|
45
|
+
// Scale all numbers to integers
|
|
46
|
+
var scaledNumbers = allNumbers.map(function (number_) {
|
|
47
|
+
return Math.round(number_ * multiplier);
|
|
48
|
+
});
|
|
49
|
+
var result = _gcdInteger.apply(void 0, [scaledNumbers[0], scaledNumbers[1]].concat(_toConsumableArray(scaledNumbers.slice(2))));
|
|
50
|
+
|
|
51
|
+
// Scale back to original decimal range
|
|
52
|
+
return result / multiplier;
|
|
53
|
+
}
|
|
54
|
+
return _gcdInteger.apply(void 0, [x, y].concat(z));
|
|
55
|
+
};
|
|
56
|
+
var _gcdInteger = function gcdInteger(x, y) {
|
|
57
|
+
var copyX = Math.abs(Math.round(x));
|
|
58
|
+
var copyY = Math.abs(Math.round(y));
|
|
59
|
+
for (var _len2 = arguments.length, z = new Array(_len2 > 2 ? _len2 - 2 : 0), _key2 = 2; _key2 < _len2; _key2++) {
|
|
60
|
+
z[_key2 - 2] = arguments[_key2];
|
|
61
|
+
}
|
|
24
62
|
var copyZ = z.map(function (element) {
|
|
25
|
-
return Math.abs(element);
|
|
63
|
+
return Math.abs(Math.round(element));
|
|
26
64
|
});
|
|
27
65
|
if (copyX === 0 || copyY === 0) {
|
|
28
66
|
return 0;
|
|
@@ -43,7 +81,7 @@ var _gcd = exports.gcd = function gcd(x, y) {
|
|
|
43
81
|
try {
|
|
44
82
|
for (_iterator.s(); !(_step = _iterator.n()).done;) {
|
|
45
83
|
var element = _step.value;
|
|
46
|
-
copyX =
|
|
84
|
+
copyX = _gcdInteger(copyX, element);
|
|
47
85
|
}
|
|
48
86
|
} catch (err) {
|
|
49
87
|
_iterator.e(err);
|
|
@@ -2,6 +2,7 @@ export * from "./addition";
|
|
|
2
2
|
export * from "./average";
|
|
3
3
|
export * from "./bitwise";
|
|
4
4
|
export * from "./calculator";
|
|
5
|
+
export * from "./correlationCoefficient";
|
|
5
6
|
export * from "./degToRad";
|
|
6
7
|
export * from "./deviationValue";
|
|
7
8
|
export * from "./division";
|
|
@@ -17,11 +18,13 @@ export * from "./mathSeparator";
|
|
|
17
18
|
export * from "./max";
|
|
18
19
|
export * from "./median";
|
|
19
20
|
export * from "./min";
|
|
21
|
+
export * from "./mode";
|
|
20
22
|
export * from "./multiples";
|
|
21
23
|
export * from "./multiplication";
|
|
22
24
|
export * from "./nCr";
|
|
23
25
|
export * from "./nHr";
|
|
24
26
|
export * from "./nPr";
|
|
27
|
+
export * from "./percentile";
|
|
25
28
|
export * from "./primeFactorization";
|
|
26
29
|
export * from "./quotient";
|
|
27
30
|
export * from "./radToDeg";
|
package/module/es5/Math/index.js
CHANGED
|
@@ -47,6 +47,17 @@ Object.keys(_calculator).forEach(function (key) {
|
|
|
47
47
|
}
|
|
48
48
|
});
|
|
49
49
|
});
|
|
50
|
+
var _correlationCoefficient = require("./correlationCoefficient");
|
|
51
|
+
Object.keys(_correlationCoefficient).forEach(function (key) {
|
|
52
|
+
if (key === "default" || key === "__esModule") return;
|
|
53
|
+
if (key in exports && exports[key] === _correlationCoefficient[key]) return;
|
|
54
|
+
Object.defineProperty(exports, key, {
|
|
55
|
+
enumerable: true,
|
|
56
|
+
get: function get() {
|
|
57
|
+
return _correlationCoefficient[key];
|
|
58
|
+
}
|
|
59
|
+
});
|
|
60
|
+
});
|
|
50
61
|
var _degToRad = require("./degToRad");
|
|
51
62
|
Object.keys(_degToRad).forEach(function (key) {
|
|
52
63
|
if (key === "default" || key === "__esModule") return;
|
|
@@ -212,6 +223,17 @@ Object.keys(_min).forEach(function (key) {
|
|
|
212
223
|
}
|
|
213
224
|
});
|
|
214
225
|
});
|
|
226
|
+
var _mode = require("./mode");
|
|
227
|
+
Object.keys(_mode).forEach(function (key) {
|
|
228
|
+
if (key === "default" || key === "__esModule") return;
|
|
229
|
+
if (key in exports && exports[key] === _mode[key]) return;
|
|
230
|
+
Object.defineProperty(exports, key, {
|
|
231
|
+
enumerable: true,
|
|
232
|
+
get: function get() {
|
|
233
|
+
return _mode[key];
|
|
234
|
+
}
|
|
235
|
+
});
|
|
236
|
+
});
|
|
215
237
|
var _multiples = require("./multiples");
|
|
216
238
|
Object.keys(_multiples).forEach(function (key) {
|
|
217
239
|
if (key === "default" || key === "__esModule") return;
|
|
@@ -267,6 +289,17 @@ Object.keys(_nPr).forEach(function (key) {
|
|
|
267
289
|
}
|
|
268
290
|
});
|
|
269
291
|
});
|
|
292
|
+
var _percentile = require("./percentile");
|
|
293
|
+
Object.keys(_percentile).forEach(function (key) {
|
|
294
|
+
if (key === "default" || key === "__esModule") return;
|
|
295
|
+
if (key in exports && exports[key] === _percentile[key]) return;
|
|
296
|
+
Object.defineProperty(exports, key, {
|
|
297
|
+
enumerable: true,
|
|
298
|
+
get: function get() {
|
|
299
|
+
return _percentile[key];
|
|
300
|
+
}
|
|
301
|
+
});
|
|
302
|
+
});
|
|
270
303
|
var _primeFactorization = require("./primeFactorization");
|
|
271
304
|
Object.keys(_primeFactorization).forEach(function (key) {
|
|
272
305
|
if (key === "default" || key === "__esModule") return;
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Finds the most frequently occurring value(s) in an array
|
|
3
|
+
* @param array - Array of numbers to find mode for
|
|
4
|
+
* @returns Array of mode values (can be multiple values if there are ties)
|
|
5
|
+
* @example
|
|
6
|
+
* mode([1, 2, 2, 3, 3, 3]); // [3]
|
|
7
|
+
* mode([1, 2, 2, 3, 3]); // [2, 3]
|
|
8
|
+
* mode([1, 2, 3]); // [1, 2, 3]
|
|
9
|
+
*/
|
|
10
|
+
export declare const mode: (array: number[]) => number[];
|
|
@@ -0,0 +1,67 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.mode = void 0;
|
|
7
|
+
function _slicedToArray(r, e) { return _arrayWithHoles(r) || _iterableToArrayLimit(r, e) || _unsupportedIterableToArray(r, e) || _nonIterableRest(); }
|
|
8
|
+
function _nonIterableRest() { throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); }
|
|
9
|
+
function _iterableToArrayLimit(r, l) { var t = null == r ? null : "undefined" != typeof Symbol && r[Symbol.iterator] || r["@@iterator"]; if (null != t) { var e, n, i, u, a = [], f = !0, o = !1; try { if (i = (t = t.call(r)).next, 0 === l) { if (Object(t) !== t) return; f = !1; } else for (; !(f = (e = i.call(t)).done) && (a.push(e.value), a.length !== l); f = !0); } catch (r) { o = !0, n = r; } finally { try { if (!f && null != t["return"] && (u = t["return"](), Object(u) !== u)) return; } finally { if (o) throw n; } } return a; } }
|
|
10
|
+
function _arrayWithHoles(r) { if (Array.isArray(r)) return r; }
|
|
11
|
+
function _createForOfIteratorHelper(r, e) { var t = "undefined" != typeof Symbol && r[Symbol.iterator] || r["@@iterator"]; if (!t) { if (Array.isArray(r) || (t = _unsupportedIterableToArray(r)) || e && r && "number" == typeof r.length) { t && (r = t); var _n = 0, F = function F() {}; return { s: F, n: function n() { return _n >= r.length ? { done: !0 } : { done: !1, value: r[_n++] }; }, e: function e(r) { throw r; }, f: F }; } throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); } var o, a = !0, u = !1; return { s: function s() { t = t.call(r); }, n: function n() { var r = t.next(); return a = r.done, r; }, e: function e(r) { u = !0, o = r; }, f: function f() { try { a || null == t["return"] || t["return"](); } finally { if (u) throw o; } } }; }
|
|
12
|
+
function _unsupportedIterableToArray(r, a) { if (r) { if ("string" == typeof r) return _arrayLikeToArray(r, a); var t = {}.toString.call(r).slice(8, -1); return "Object" === t && r.constructor && (t = r.constructor.name), "Map" === t || "Set" === t ? Array.from(r) : "Arguments" === t || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(t) ? _arrayLikeToArray(r, a) : void 0; } }
|
|
13
|
+
function _arrayLikeToArray(r, a) { (null == a || a > r.length) && (a = r.length); for (var e = 0, n = Array(a); e < a; e++) n[e] = r[e]; return n; }
|
|
14
|
+
/**
|
|
15
|
+
* Finds the most frequently occurring value(s) in an array
|
|
16
|
+
* @param array - Array of numbers to find mode for
|
|
17
|
+
* @returns Array of mode values (can be multiple values if there are ties)
|
|
18
|
+
* @example
|
|
19
|
+
* mode([1, 2, 2, 3, 3, 3]); // [3]
|
|
20
|
+
* mode([1, 2, 2, 3, 3]); // [2, 3]
|
|
21
|
+
* mode([1, 2, 3]); // [1, 2, 3]
|
|
22
|
+
*/
|
|
23
|
+
var mode = exports.mode = function mode(array) {
|
|
24
|
+
if (array.length === 0) {
|
|
25
|
+
return [];
|
|
26
|
+
}
|
|
27
|
+
var frequency = new Map();
|
|
28
|
+
var maxFrequency = 0;
|
|
29
|
+
|
|
30
|
+
// Count frequencies
|
|
31
|
+
var _iterator = _createForOfIteratorHelper(array),
|
|
32
|
+
_step;
|
|
33
|
+
try {
|
|
34
|
+
for (_iterator.s(); !(_step = _iterator.n()).done;) {
|
|
35
|
+
var value = _step.value;
|
|
36
|
+
var count = (frequency.get(value) || 0) + 1;
|
|
37
|
+
frequency.set(value, count);
|
|
38
|
+
maxFrequency = Math.max(maxFrequency, count);
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
// Find all values with maximum frequency
|
|
42
|
+
} catch (err) {
|
|
43
|
+
_iterator.e(err);
|
|
44
|
+
} finally {
|
|
45
|
+
_iterator.f();
|
|
46
|
+
}
|
|
47
|
+
var modes = [];
|
|
48
|
+
var _iterator2 = _createForOfIteratorHelper(frequency),
|
|
49
|
+
_step2;
|
|
50
|
+
try {
|
|
51
|
+
for (_iterator2.s(); !(_step2 = _iterator2.n()).done;) {
|
|
52
|
+
var _step2$value = _slicedToArray(_step2.value, 2),
|
|
53
|
+
_value = _step2$value[0],
|
|
54
|
+
_count = _step2$value[1];
|
|
55
|
+
if (_count === maxFrequency) {
|
|
56
|
+
modes.push(_value);
|
|
57
|
+
}
|
|
58
|
+
}
|
|
59
|
+
} catch (err) {
|
|
60
|
+
_iterator2.e(err);
|
|
61
|
+
} finally {
|
|
62
|
+
_iterator2.f();
|
|
63
|
+
}
|
|
64
|
+
return modes.sort(function (a, b) {
|
|
65
|
+
return a - b;
|
|
66
|
+
});
|
|
67
|
+
};
|