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,11 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Calculate the nth percentile of values in an array
|
|
3
|
+
* @param array - Array of numbers
|
|
4
|
+
* @param percentile - Percentile value (0-100)
|
|
5
|
+
* @returns The percentile value
|
|
6
|
+
* @example
|
|
7
|
+
* percentile([1, 2, 3, 4, 5], 50); // 3 (50th percentile - median)
|
|
8
|
+
* percentile([1, 2, 3, 4, 5], 25); // 2 (25th percentile)
|
|
9
|
+
* percentile([1, 2, 3, 4, 5], 75); // 4 (75th percentile)
|
|
10
|
+
*/
|
|
11
|
+
export declare const percentile: (array: number[], percentile: number) => number;
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.percentile = void 0;
|
|
7
|
+
var _quickSort = require("@/Array/quickSort");
|
|
8
|
+
function _toConsumableArray(r) { return _arrayWithoutHoles(r) || _iterableToArray(r) || _unsupportedIterableToArray(r) || _nonIterableSpread(); }
|
|
9
|
+
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."); }
|
|
10
|
+
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; } }
|
|
11
|
+
function _iterableToArray(r) { if ("undefined" != typeof Symbol && null != r[Symbol.iterator] || null != r["@@iterator"]) return Array.from(r); }
|
|
12
|
+
function _arrayWithoutHoles(r) { if (Array.isArray(r)) return _arrayLikeToArray(r); }
|
|
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
|
+
* Calculate the nth percentile of values in an array
|
|
16
|
+
* @param array - Array of numbers
|
|
17
|
+
* @param percentile - Percentile value (0-100)
|
|
18
|
+
* @returns The percentile value
|
|
19
|
+
* @example
|
|
20
|
+
* percentile([1, 2, 3, 4, 5], 50); // 3 (50th percentile - median)
|
|
21
|
+
* percentile([1, 2, 3, 4, 5], 25); // 2 (25th percentile)
|
|
22
|
+
* percentile([1, 2, 3, 4, 5], 75); // 4 (75th percentile)
|
|
23
|
+
*/
|
|
24
|
+
var percentile = exports.percentile = function percentile(array, _percentile) {
|
|
25
|
+
if (array.length === 0) {
|
|
26
|
+
return Number.NaN;
|
|
27
|
+
}
|
|
28
|
+
if (_percentile < 0 || _percentile > 100) {
|
|
29
|
+
throw new Error("Percentile must be between 0 and 100");
|
|
30
|
+
}
|
|
31
|
+
var sortedArray = (0, _quickSort.quickSort)(_toConsumableArray(array));
|
|
32
|
+
var index = _percentile / 100 * (sortedArray.length - 1);
|
|
33
|
+
var lowerIndex = Math.floor(index);
|
|
34
|
+
var upperIndex = Math.ceil(index);
|
|
35
|
+
if (lowerIndex === upperIndex) {
|
|
36
|
+
return sortedArray[lowerIndex];
|
|
37
|
+
}
|
|
38
|
+
var lowerValue = sortedArray[lowerIndex];
|
|
39
|
+
var upperValue = sortedArray[upperIndex];
|
|
40
|
+
var weight = index - lowerIndex;
|
|
41
|
+
return lowerValue + (upperValue - lowerValue) * weight;
|
|
42
|
+
};
|
|
@@ -5,6 +5,8 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
5
5
|
});
|
|
6
6
|
exports.standardDeviation = void 0;
|
|
7
7
|
var _average = require("./average");
|
|
8
|
+
var _multiplication = require("@/Math/multiplication");
|
|
9
|
+
var _subtract = require("@/Math/subtract");
|
|
8
10
|
/**
|
|
9
11
|
* Calculates the standard deviation of a set of values
|
|
10
12
|
* @param {number[]} values Array of numeric values
|
|
@@ -21,8 +23,8 @@ var standardDeviation = exports.standardDeviation = function standardDeviation(v
|
|
|
21
23
|
|
|
22
24
|
// Calculate the squared differences from the mean
|
|
23
25
|
var squareDiffs = values.map(function (value) {
|
|
24
|
-
var diff = value
|
|
25
|
-
return diff
|
|
26
|
+
var diff = (0, _subtract.subtract)(value, avg);
|
|
27
|
+
return (0, _multiplication.multiplication)(diff, diff);
|
|
26
28
|
});
|
|
27
29
|
|
|
28
30
|
// Calculate the mean of the squared differences
|
package/module/es5/Object/has.js
CHANGED
|
@@ -30,7 +30,7 @@ var has = exports.has = function has(object, path) {
|
|
|
30
30
|
try {
|
|
31
31
|
for (_iterator.s(); !(_step = _iterator.n()).done;) {
|
|
32
32
|
var _key = _step.value;
|
|
33
|
-
if (current == null || !Object.
|
|
33
|
+
if (current == null || !Object.hasOwn(current, _key)) {
|
|
34
34
|
return false;
|
|
35
35
|
}
|
|
36
36
|
current = current[_key];
|
|
@@ -14,6 +14,17 @@ Object.keys(_has).forEach(function (key) {
|
|
|
14
14
|
}
|
|
15
15
|
});
|
|
16
16
|
});
|
|
17
|
+
var _isEmpty = require("./isEmpty");
|
|
18
|
+
Object.keys(_isEmpty).forEach(function (key) {
|
|
19
|
+
if (key === "default" || key === "__esModule") return;
|
|
20
|
+
if (key in exports && exports[key] === _isEmpty[key]) return;
|
|
21
|
+
Object.defineProperty(exports, key, {
|
|
22
|
+
enumerable: true,
|
|
23
|
+
get: function get() {
|
|
24
|
+
return _isEmpty[key];
|
|
25
|
+
}
|
|
26
|
+
});
|
|
27
|
+
});
|
|
17
28
|
var _keyBy = require("./keyBy");
|
|
18
29
|
Object.keys(_keyBy).forEach(function (key) {
|
|
19
30
|
if (key === "default" || key === "__esModule") return;
|
|
@@ -25,6 +36,39 @@ Object.keys(_keyBy).forEach(function (key) {
|
|
|
25
36
|
}
|
|
26
37
|
});
|
|
27
38
|
});
|
|
39
|
+
var _merge = require("./merge");
|
|
40
|
+
Object.keys(_merge).forEach(function (key) {
|
|
41
|
+
if (key === "default" || key === "__esModule") return;
|
|
42
|
+
if (key in exports && exports[key] === _merge[key]) return;
|
|
43
|
+
Object.defineProperty(exports, key, {
|
|
44
|
+
enumerable: true,
|
|
45
|
+
get: function get() {
|
|
46
|
+
return _merge[key];
|
|
47
|
+
}
|
|
48
|
+
});
|
|
49
|
+
});
|
|
50
|
+
var _mergeDeep = require("./mergeDeep");
|
|
51
|
+
Object.keys(_mergeDeep).forEach(function (key) {
|
|
52
|
+
if (key === "default" || key === "__esModule") return;
|
|
53
|
+
if (key in exports && exports[key] === _mergeDeep[key]) return;
|
|
54
|
+
Object.defineProperty(exports, key, {
|
|
55
|
+
enumerable: true,
|
|
56
|
+
get: function get() {
|
|
57
|
+
return _mergeDeep[key];
|
|
58
|
+
}
|
|
59
|
+
});
|
|
60
|
+
});
|
|
61
|
+
var _omit = require("./omit");
|
|
62
|
+
Object.keys(_omit).forEach(function (key) {
|
|
63
|
+
if (key === "default" || key === "__esModule") return;
|
|
64
|
+
if (key in exports && exports[key] === _omit[key]) return;
|
|
65
|
+
Object.defineProperty(exports, key, {
|
|
66
|
+
enumerable: true,
|
|
67
|
+
get: function get() {
|
|
68
|
+
return _omit[key];
|
|
69
|
+
}
|
|
70
|
+
});
|
|
71
|
+
});
|
|
28
72
|
var _pick = require("./pick");
|
|
29
73
|
Object.keys(_pick).forEach(function (key) {
|
|
30
74
|
if (key === "default" || key === "__esModule") return;
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.isEmpty = void 0;
|
|
7
|
+
/**
|
|
8
|
+
* Checks if an object is empty (has no own properties)
|
|
9
|
+
* @param object - The object to check
|
|
10
|
+
* @returns true if the object is empty, false otherwise
|
|
11
|
+
*/
|
|
12
|
+
var isEmpty = exports.isEmpty = function isEmpty(object) {
|
|
13
|
+
// Check enumerable string keys
|
|
14
|
+
for (var key in object) {
|
|
15
|
+
if (Object.hasOwn(object, key)) {
|
|
16
|
+
return false;
|
|
17
|
+
}
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
// Check symbol properties
|
|
21
|
+
var symbolKeys = Object.getOwnPropertySymbols(object);
|
|
22
|
+
if (symbolKeys.length > 0) {
|
|
23
|
+
return false;
|
|
24
|
+
}
|
|
25
|
+
return true;
|
|
26
|
+
};
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import type { UnionToIntersection } from "$/logic/unionToIntersection";
|
|
2
|
+
/**
|
|
3
|
+
* Merges multiple objects into a single object (shallow merge)
|
|
4
|
+
* @param target - The target object to merge into
|
|
5
|
+
* @param sources - The source objects to merge from
|
|
6
|
+
* @returns The merged object
|
|
7
|
+
*/
|
|
8
|
+
export declare const merge: <T extends Record<string, unknown>, U extends Record<string, unknown>[]>(target: T, ...sources: U) => T & UnionToIntersection<U[number]>;
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.merge = void 0;
|
|
7
|
+
/**
|
|
8
|
+
* Merges multiple objects into a single object (shallow merge)
|
|
9
|
+
* @param target - The target object to merge into
|
|
10
|
+
* @param sources - The source objects to merge from
|
|
11
|
+
* @returns The merged object
|
|
12
|
+
*/
|
|
13
|
+
var merge = exports.merge = function merge(target) {
|
|
14
|
+
for (var _len = arguments.length, sources = new Array(_len > 1 ? _len - 1 : 0), _key = 1; _key < _len; _key++) {
|
|
15
|
+
sources[_key - 1] = arguments[_key];
|
|
16
|
+
}
|
|
17
|
+
return Object.assign.apply(Object, [{}, target].concat(sources));
|
|
18
|
+
};
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import type { UnionToIntersection } from "$/logic/unionToIntersection";
|
|
2
|
+
/**
|
|
3
|
+
* Deeply merges multiple objects into a single object
|
|
4
|
+
* @param target - The target object to merge into
|
|
5
|
+
* @param sources - The source objects to merge from
|
|
6
|
+
* @returns The deeply merged object
|
|
7
|
+
*/
|
|
8
|
+
export declare const mergeDeep: <T extends Record<string, unknown>, U extends Record<string, unknown>[]>(target: T, ...sources: U) => T & UnionToIntersection<U[number]>;
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.mergeDeep = void 0;
|
|
7
|
+
function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
|
|
8
|
+
function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
|
|
9
|
+
function _defineProperty(e, r, t) { return (r = _toPropertyKey(r)) in e ? Object.defineProperty(e, r, { value: t, enumerable: !0, configurable: !0, writable: !0 }) : e[r] = t, e; }
|
|
10
|
+
function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == _typeof(i) ? i : i + ""; }
|
|
11
|
+
function _toPrimitive(t, r) { if ("object" != _typeof(t) || !t) return t; var e = t[Symbol.toPrimitive]; if (void 0 !== e) { var i = e.call(t, r || "default"); if ("object" != _typeof(i)) return i; throw new TypeError("@@toPrimitive must return a primitive value."); } return ("string" === r ? String : Number)(t); }
|
|
12
|
+
function _typeof(o) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (o) { return typeof o; } : function (o) { return o && "function" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? "symbol" : typeof o; }, _typeof(o); }
|
|
13
|
+
/**
|
|
14
|
+
* Checks if a value is a plain object
|
|
15
|
+
*/
|
|
16
|
+
var isPlainObject = function isPlainObject(value) {
|
|
17
|
+
return value !== null && _typeof(value) === "object" && value.constructor === Object && Object.prototype.toString.call(value) === "[object Object]";
|
|
18
|
+
};
|
|
19
|
+
|
|
20
|
+
/**
|
|
21
|
+
* Deeply merges multiple objects into a single object
|
|
22
|
+
* @param target - The target object to merge into
|
|
23
|
+
* @param sources - The source objects to merge from
|
|
24
|
+
* @returns The deeply merged object
|
|
25
|
+
*/
|
|
26
|
+
var _mergeDeep = exports.mergeDeep = function mergeDeep(target) {
|
|
27
|
+
for (var _len = arguments.length, sources = new Array(_len > 1 ? _len - 1 : 0), _key = 1; _key < _len; _key++) {
|
|
28
|
+
sources[_key - 1] = arguments[_key];
|
|
29
|
+
}
|
|
30
|
+
if (sources.length === 0) {
|
|
31
|
+
return target;
|
|
32
|
+
}
|
|
33
|
+
var source = sources.shift();
|
|
34
|
+
if (isPlainObject(target) && isPlainObject(source)) {
|
|
35
|
+
var result = _objectSpread({}, target);
|
|
36
|
+
for (var key in source) {
|
|
37
|
+
if (Object.hasOwn(source, key)) {
|
|
38
|
+
var sourceValue = source[key];
|
|
39
|
+
var targetValue = result[key];
|
|
40
|
+
result[key] = isPlainObject(targetValue) && isPlainObject(sourceValue) ? _mergeDeep(targetValue, sourceValue) : sourceValue;
|
|
41
|
+
}
|
|
42
|
+
}
|
|
43
|
+
return _mergeDeep.apply(void 0, [result].concat(sources));
|
|
44
|
+
}
|
|
45
|
+
return _mergeDeep.apply(void 0, [source].concat(sources));
|
|
46
|
+
};
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Creates an object without the specified keys
|
|
3
|
+
* @param object - The source object
|
|
4
|
+
* @param keys - The keys to omit
|
|
5
|
+
* @returns A new object without the specified keys
|
|
6
|
+
*/
|
|
7
|
+
export declare const omit: <T extends object, K extends keyof T>(object: T, ...keys: K[]) => Omit<T, K>;
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.omit = void 0;
|
|
7
|
+
function _typeof(o) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (o) { return typeof o; } : function (o) { return o && "function" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? "symbol" : typeof o; }, _typeof(o); }
|
|
8
|
+
function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
|
|
9
|
+
function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
|
|
10
|
+
function _defineProperty(e, r, t) { return (r = _toPropertyKey(r)) in e ? Object.defineProperty(e, r, { value: t, enumerable: !0, configurable: !0, writable: !0 }) : e[r] = t, e; }
|
|
11
|
+
function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == _typeof(i) ? i : i + ""; }
|
|
12
|
+
function _toPrimitive(t, r) { if ("object" != _typeof(t) || !t) return t; var e = t[Symbol.toPrimitive]; if (void 0 !== e) { var i = e.call(t, r || "default"); if ("object" != _typeof(i)) return i; throw new TypeError("@@toPrimitive must return a primitive value."); } return ("string" === r ? String : Number)(t); }
|
|
13
|
+
/**
|
|
14
|
+
* Creates an object without the specified keys
|
|
15
|
+
* @param object - The source object
|
|
16
|
+
* @param keys - The keys to omit
|
|
17
|
+
* @returns A new object without the specified keys
|
|
18
|
+
*/
|
|
19
|
+
var omit = exports.omit = function omit(object) {
|
|
20
|
+
var result = _objectSpread({}, object);
|
|
21
|
+
for (var _len = arguments.length, keys = new Array(_len > 1 ? _len - 1 : 0), _key = 1; _key < _len; _key++) {
|
|
22
|
+
keys[_key - 1] = arguments[_key];
|
|
23
|
+
}
|
|
24
|
+
for (var _i = 0, _keys = keys; _i < _keys.length; _i++) {
|
|
25
|
+
var key = _keys[_i];
|
|
26
|
+
delete result[key];
|
|
27
|
+
}
|
|
28
|
+
return result;
|
|
29
|
+
};
|
|
@@ -7,7 +7,7 @@ import type { PickDeepKey } from "$/object/pickDeepKey";
|
|
|
7
7
|
* @template K - Type of property keys to select. Must be a subset of PickDeepKey<T>.
|
|
8
8
|
* @param {T} object - The source object to extract properties from.
|
|
9
9
|
* @param {...K[]} keys - Property keys to extract. Can use dot notation for nested properties.
|
|
10
|
-
* @returns {PickDeep<T>} A new object containing only the specified properties.
|
|
10
|
+
* @returns {PickDeep<T, K>} A new object containing only the specified properties.
|
|
11
11
|
*
|
|
12
12
|
* @example
|
|
13
13
|
* ```typescript
|
|
@@ -16,4 +16,4 @@ import type { PickDeepKey } from "$/object/pickDeepKey";
|
|
|
16
16
|
* // picked will be { a: { b: { c: 1 } }, f: 4 }
|
|
17
17
|
* ```
|
|
18
18
|
*/
|
|
19
|
-
export declare const pickDeep: <T extends object, K extends PickDeepKey<T
|
|
19
|
+
export declare const pickDeep: <T extends object, const K extends readonly PickDeepKey<T>[]>(object: T, ...keys: K) => PickDeep<T, K>;
|
|
@@ -24,7 +24,7 @@ function _toPrimitive(t, r) { if ("object" != _typeof(t) || !t) return t; var e
|
|
|
24
24
|
* @template K - Type of property keys to select. Must be a subset of PickDeepKey<T>.
|
|
25
25
|
* @param {T} object - The source object to extract properties from.
|
|
26
26
|
* @param {...K[]} keys - Property keys to extract. Can use dot notation for nested properties.
|
|
27
|
-
* @returns {PickDeep<T>} A new object containing only the specified properties.
|
|
27
|
+
* @returns {PickDeep<T, K>} A new object containing only the specified properties.
|
|
28
28
|
*
|
|
29
29
|
* @example
|
|
30
30
|
* ```typescript
|
|
@@ -34,7 +34,7 @@ function _toPrimitive(t, r) { if ("object" != _typeof(t) || !t) return t; var e
|
|
|
34
34
|
* ```
|
|
35
35
|
*/
|
|
36
36
|
var pickDeep = exports.pickDeep = function pickDeep(object) {
|
|
37
|
-
// biome-ignore lint/suspicious/noExplicitAny:
|
|
37
|
+
// biome-ignore lint/suspicious/noExplicitAny: ignore
|
|
38
38
|
var result = {};
|
|
39
39
|
for (var _len = arguments.length, keys = new Array(_len > 1 ? _len - 1 : 0), _key = 1; _key < _len; _key++) {
|
|
40
40
|
keys[_key - 1] = arguments[_key];
|
|
@@ -42,9 +42,9 @@ var pickDeep = exports.pickDeep = function pickDeep(object) {
|
|
|
42
42
|
for (var _i = 0, _keys = keys; _i < _keys.length; _i++) {
|
|
43
43
|
var key = _keys[_i];
|
|
44
44
|
var parts = key.split(".");
|
|
45
|
-
// biome-ignore lint/suspicious/noExplicitAny:
|
|
45
|
+
// biome-ignore lint/suspicious/noExplicitAny: ignore
|
|
46
46
|
var current = _objectSpread({}, object);
|
|
47
|
-
// biome-ignore lint/suspicious/noExplicitAny:
|
|
47
|
+
// biome-ignore lint/suspicious/noExplicitAny: ignore
|
|
48
48
|
var target = result;
|
|
49
49
|
var _iterator = _createForOfIteratorHelper(parts.entries()),
|
|
50
50
|
_step;
|
|
@@ -28,7 +28,7 @@ function dayOfWeekSimple(properties) {
|
|
|
28
28
|
if (typeof properties === "string") {
|
|
29
29
|
if (properties.includes(":")) {
|
|
30
30
|
var _ref = properties.split(":")
|
|
31
|
-
// biome-ignore lint/suspicious/noExplicitAny:
|
|
31
|
+
// biome-ignore lint/suspicious/noExplicitAny: ignore
|
|
32
32
|
.map(Number),
|
|
33
33
|
_ref2 = _slicedToArray(_ref, 3),
|
|
34
34
|
_year = _ref2[0],
|
|
@@ -42,7 +42,7 @@ function dayOfWeekSimple(properties) {
|
|
|
42
42
|
}
|
|
43
43
|
if (properties.includes("/")) {
|
|
44
44
|
var _ref3 = properties.split("/")
|
|
45
|
-
// biome-ignore lint/suspicious/noExplicitAny:
|
|
45
|
+
// biome-ignore lint/suspicious/noExplicitAny: ignore
|
|
46
46
|
.map(Number),
|
|
47
47
|
_ref4 = _slicedToArray(_ref3, 3),
|
|
48
48
|
_year2 = _ref4[0],
|
|
@@ -55,7 +55,7 @@ function dayOfWeekSimple(properties) {
|
|
|
55
55
|
}, timeDifference);
|
|
56
56
|
}
|
|
57
57
|
var _ref5 = properties.split("-")
|
|
58
|
-
// biome-ignore lint/suspicious/noExplicitAny:
|
|
58
|
+
// biome-ignore lint/suspicious/noExplicitAny: ignore
|
|
59
59
|
.map(Number),
|
|
60
60
|
_ref6 = _slicedToArray(_ref5, 3),
|
|
61
61
|
year = _ref6[0],
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.camelCase = void 0;
|
|
7
|
+
/**
|
|
8
|
+
* Converts a string to camelCase
|
|
9
|
+
* @param str - The string to convert
|
|
10
|
+
* @returns The camelCase string
|
|
11
|
+
*/
|
|
12
|
+
var camelCase = exports.camelCase = function camelCase(string_) {
|
|
13
|
+
return string_.replaceAll(/[^a-zA-Z0-9]+(.)/g, function (_, _char) {
|
|
14
|
+
return _char.toUpperCase();
|
|
15
|
+
}).replaceAll(/[^a-zA-Z0-9]+$/g, "").replace(/^[A-Z]/, function (_char2) {
|
|
16
|
+
return _char2.toLowerCase();
|
|
17
|
+
});
|
|
18
|
+
};
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.escapeHtml = void 0;
|
|
7
|
+
/**
|
|
8
|
+
* HTML entities map for escaping
|
|
9
|
+
*/
|
|
10
|
+
var htmlEscapeMap = {
|
|
11
|
+
"&": "&",
|
|
12
|
+
"<": "<",
|
|
13
|
+
">": ">",
|
|
14
|
+
'"': """,
|
|
15
|
+
"'": "'"
|
|
16
|
+
};
|
|
17
|
+
|
|
18
|
+
/**
|
|
19
|
+
* Escapes HTML special characters in a string
|
|
20
|
+
* @param str - The string to escape
|
|
21
|
+
* @returns The escaped string
|
|
22
|
+
*/
|
|
23
|
+
var escapeHtml = exports.escapeHtml = function escapeHtml(string_) {
|
|
24
|
+
return string_.replaceAll(/[&<>"']/g, function (match) {
|
|
25
|
+
return htmlEscapeMap[match];
|
|
26
|
+
});
|
|
27
|
+
};
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import type { Formatter } from "$/string/formatString/formatter";
|
|
2
|
+
/**
|
|
3
|
+
* Applies a formatter function to a value with optional arguments.
|
|
4
|
+
*
|
|
5
|
+
* Parses formatter syntax like "upper", "currency(ja-JP,JPY)", "pad(4,0)" and applies
|
|
6
|
+
* the corresponding formatter function with parsed arguments.
|
|
7
|
+
*
|
|
8
|
+
* @param value - The value to format
|
|
9
|
+
* @param formatterString - Formatter name with optional arguments (e.g., "upper", "currency(ja-JP,JPY)")
|
|
10
|
+
* @param formatters - Available formatter functions
|
|
11
|
+
* @returns Formatted string, or original string value if formatter not found/invalid
|
|
12
|
+
*
|
|
13
|
+
* @example
|
|
14
|
+
* // Simple formatter
|
|
15
|
+
* applyFormatter("hello", "upper", { upper: (v) => String(v).toUpperCase() }) // → "HELLO"
|
|
16
|
+
*
|
|
17
|
+
* @example
|
|
18
|
+
* // Formatter with arguments
|
|
19
|
+
* applyFormatter(42, "pad(4,0)", { pad: (v, len, char) => String(v).padStart(+len, char) }) // → "0042"
|
|
20
|
+
*
|
|
21
|
+
* @example
|
|
22
|
+
* // Invalid formatter returns original value
|
|
23
|
+
* applyFormatter("test", "invalid!@#", {}) // → "test"
|
|
24
|
+
*/
|
|
25
|
+
export declare function applyFormatter(value: unknown, formatterString: string, formatters: Record<string, Formatter>): string;
|
|
@@ -0,0 +1,100 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.applyFormatter = applyFormatter;
|
|
7
|
+
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; } } }; }
|
|
8
|
+
function _toConsumableArray(r) { return _arrayWithoutHoles(r) || _iterableToArray(r) || _unsupportedIterableToArray(r) || _nonIterableSpread(); }
|
|
9
|
+
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."); }
|
|
10
|
+
function _iterableToArray(r) { if ("undefined" != typeof Symbol && null != r[Symbol.iterator] || null != r["@@iterator"]) return Array.from(r); }
|
|
11
|
+
function _arrayWithoutHoles(r) { if (Array.isArray(r)) return _arrayLikeToArray(r); }
|
|
12
|
+
function _slicedToArray(r, e) { return _arrayWithHoles(r) || _iterableToArrayLimit(r, e) || _unsupportedIterableToArray(r, e) || _nonIterableRest(); }
|
|
13
|
+
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."); }
|
|
14
|
+
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; } }
|
|
15
|
+
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; }
|
|
16
|
+
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; } }
|
|
17
|
+
function _arrayWithHoles(r) { if (Array.isArray(r)) return r; }
|
|
18
|
+
/**
|
|
19
|
+
* Applies a formatter function to a value with optional arguments.
|
|
20
|
+
*
|
|
21
|
+
* Parses formatter syntax like "upper", "currency(ja-JP,JPY)", "pad(4,0)" and applies
|
|
22
|
+
* the corresponding formatter function with parsed arguments.
|
|
23
|
+
*
|
|
24
|
+
* @param value - The value to format
|
|
25
|
+
* @param formatterString - Formatter name with optional arguments (e.g., "upper", "currency(ja-JP,JPY)")
|
|
26
|
+
* @param formatters - Available formatter functions
|
|
27
|
+
* @returns Formatted string, or original string value if formatter not found/invalid
|
|
28
|
+
*
|
|
29
|
+
* @example
|
|
30
|
+
* // Simple formatter
|
|
31
|
+
* applyFormatter("hello", "upper", { upper: (v) => String(v).toUpperCase() }) // → "HELLO"
|
|
32
|
+
*
|
|
33
|
+
* @example
|
|
34
|
+
* // Formatter with arguments
|
|
35
|
+
* applyFormatter(42, "pad(4,0)", { pad: (v, len, char) => String(v).padStart(+len, char) }) // → "0042"
|
|
36
|
+
*
|
|
37
|
+
* @example
|
|
38
|
+
* // Invalid formatter returns original value
|
|
39
|
+
* applyFormatter("test", "invalid!@#", {}) // → "test"
|
|
40
|
+
*/
|
|
41
|
+
function applyFormatter(value, formatterString, formatters) {
|
|
42
|
+
var match = formatterString.match(/^(\w+)(?:\(([^)]*)\))?$/);
|
|
43
|
+
if (!match) {
|
|
44
|
+
return String(value);
|
|
45
|
+
}
|
|
46
|
+
var _match = _slicedToArray(match, 3),
|
|
47
|
+
formatterName = _match[1],
|
|
48
|
+
argumentsString = _match[2];
|
|
49
|
+
var formatter = formatters[formatterName];
|
|
50
|
+
if (!formatter) {
|
|
51
|
+
return String(value);
|
|
52
|
+
}
|
|
53
|
+
var arguments_ = argumentsString ? parseArguments(argumentsString) : [];
|
|
54
|
+
return formatter.apply(void 0, [value].concat(_toConsumableArray(arguments_)));
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
/**
|
|
58
|
+
* Parses comma-separated arguments while preserving quoted strings
|
|
59
|
+
* @param argumentsString - String containing comma-separated arguments
|
|
60
|
+
* @returns Array of parsed arguments
|
|
61
|
+
*/
|
|
62
|
+
function parseArguments(argumentsString) {
|
|
63
|
+
var arguments_ = [];
|
|
64
|
+
var current = "";
|
|
65
|
+
var inQuotes = false;
|
|
66
|
+
var quoteChar = "";
|
|
67
|
+
var _iterator = _createForOfIteratorHelper(argumentsString),
|
|
68
|
+
_step;
|
|
69
|
+
try {
|
|
70
|
+
for (_iterator.s(); !(_step = _iterator.n()).done;) {
|
|
71
|
+
var _char = _step.value;
|
|
72
|
+
if (!inQuotes && (_char === '"' || _char === "'")) {
|
|
73
|
+
inQuotes = true;
|
|
74
|
+
quoteChar = _char;
|
|
75
|
+
continue;
|
|
76
|
+
}
|
|
77
|
+
if (inQuotes && _char === quoteChar) {
|
|
78
|
+
inQuotes = false;
|
|
79
|
+
quoteChar = "";
|
|
80
|
+
continue;
|
|
81
|
+
}
|
|
82
|
+
if (!inQuotes && _char === ",") {
|
|
83
|
+
var _trimmed = current.trim();
|
|
84
|
+
arguments_.push(_trimmed === "" ? " " : _trimmed);
|
|
85
|
+
current = "";
|
|
86
|
+
continue;
|
|
87
|
+
}
|
|
88
|
+
current += _char;
|
|
89
|
+
}
|
|
90
|
+
|
|
91
|
+
// Handle last argument
|
|
92
|
+
} catch (err) {
|
|
93
|
+
_iterator.e(err);
|
|
94
|
+
} finally {
|
|
95
|
+
_iterator.f();
|
|
96
|
+
}
|
|
97
|
+
var trimmed = current.trim();
|
|
98
|
+
arguments_.push(trimmed === "" ? " " : trimmed);
|
|
99
|
+
return arguments_;
|
|
100
|
+
}
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import type { Formatter } from "$/string/formatString/formatter";
|
|
2
|
+
/**
|
|
3
|
+
* Built-in formatter functions for formatString.
|
|
4
|
+
*
|
|
5
|
+
* Each formatter takes a value and optional arguments, returning a formatted string.
|
|
6
|
+
* Formatters are used with syntax like {value:formatterName} or {value:formatterName(arg1,arg2)}.
|
|
7
|
+
*
|
|
8
|
+
* Available formatters:
|
|
9
|
+
* - upper: Convert to uppercase
|
|
10
|
+
* - lower: Convert to lowercase
|
|
11
|
+
* - currency: Format as currency with locale support
|
|
12
|
+
* - date: Format dates with locale and format options
|
|
13
|
+
* - time: Format time with locale support
|
|
14
|
+
* - number: Format numbers with precision control
|
|
15
|
+
* - plural: Choose singular/plural form based on count
|
|
16
|
+
* - pad: Pad string with characters to specified length
|
|
17
|
+
*
|
|
18
|
+
* @example
|
|
19
|
+
* // Usage in formatString
|
|
20
|
+
* formatString("{name:upper}", { name: "alice" }) // → "ALICE"
|
|
21
|
+
* formatString("{price:currency(ja-JP,JPY)}", { price: 1000 }) // → "¥1,000"
|
|
22
|
+
* formatString("{count:plural(item,items)}", { count: 1 }) // → "item"
|
|
23
|
+
*/
|
|
24
|
+
export declare const defaultFormatters: Record<string, Formatter>;
|