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
|
+
/**
|
|
2
|
+
* Recursively makes all properties in T required, including nested objects.
|
|
3
|
+
* Unlike TypeScript's built-in Required<T> which only affects top-level properties,
|
|
4
|
+
* DeepRequired<T> removes the optional modifier from all levels of nested objects.
|
|
5
|
+
*
|
|
6
|
+
* @template T - The type to make deeply required
|
|
7
|
+
*
|
|
8
|
+
* @example
|
|
9
|
+
* ```typescript
|
|
10
|
+
* interface User {
|
|
11
|
+
* id?: number;
|
|
12
|
+
* profile?: {
|
|
13
|
+
* name?: string;
|
|
14
|
+
* address?: {
|
|
15
|
+
* street?: string;
|
|
16
|
+
* city?: string;
|
|
17
|
+
* };
|
|
18
|
+
* };
|
|
19
|
+
* }
|
|
20
|
+
*
|
|
21
|
+
* type RequiredUser = DeepRequired<User>;
|
|
22
|
+
* // Result:
|
|
23
|
+
* // {
|
|
24
|
+
* // id: number;
|
|
25
|
+
* // profile: {
|
|
26
|
+
* // name: string;
|
|
27
|
+
* // address: {
|
|
28
|
+
* // street: string;
|
|
29
|
+
* // city: string;
|
|
30
|
+
* // };
|
|
31
|
+
* // };
|
|
32
|
+
* // }
|
|
33
|
+
* ```
|
|
34
|
+
*/
|
|
35
|
+
export type DeepRequired<T> = T extends Record<PropertyKey, any> ? {
|
|
36
|
+
[P in keyof T]-?: DeepRequired<T[P]>;
|
|
37
|
+
} : T;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"deepRequired.js","sourceRoot":"","sources":["../../../src/types/logic/deepRequired.ts"],"names":[],"mappings":""}
|
|
@@ -27,6 +27,8 @@ export * from "./capitalize";
|
|
|
27
27
|
export * from "./decimal1byteTobinary";
|
|
28
28
|
export * from "./decimal4bitTobinary";
|
|
29
29
|
export * from "./decimal4bitToHex";
|
|
30
|
+
export * from "./deepPartial";
|
|
31
|
+
export * from "./deepRequired";
|
|
30
32
|
export * from "./equal";
|
|
31
33
|
export * from "./first";
|
|
32
34
|
export * from "./first8Chars";
|
|
@@ -53,6 +55,7 @@ export * from "./stringReverse";
|
|
|
53
55
|
export * from "./stringToArray";
|
|
54
56
|
export * from "./stringToUnion";
|
|
55
57
|
export * from "./toNumber";
|
|
58
|
+
export * from "./unionToIntersection";
|
|
56
59
|
export * from "./xnor";
|
|
57
60
|
export * from "./xor";
|
|
58
61
|
export * from "./zeroAorB";
|
|
@@ -27,6 +27,8 @@ export * from "./capitalize";
|
|
|
27
27
|
export * from "./decimal1byteTobinary";
|
|
28
28
|
export * from "./decimal4bitTobinary";
|
|
29
29
|
export * from "./decimal4bitToHex";
|
|
30
|
+
export * from "./deepPartial";
|
|
31
|
+
export * from "./deepRequired";
|
|
30
32
|
export * from "./equal";
|
|
31
33
|
export * from "./first";
|
|
32
34
|
export * from "./first8Chars";
|
|
@@ -53,6 +55,7 @@ export * from "./stringReverse";
|
|
|
53
55
|
export * from "./stringToArray";
|
|
54
56
|
export * from "./stringToUnion";
|
|
55
57
|
export * from "./toNumber";
|
|
58
|
+
export * from "./unionToIntersection";
|
|
56
59
|
export * from "./xnor";
|
|
57
60
|
export * from "./xor";
|
|
58
61
|
export * from "./zeroAorB";
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/types/logic/index.ts"],"names":[],"mappings":"AAAA,cAAc,OAAO,CAAC;AACtB,cAAc,gBAAgB,CAAC;AAC/B,cAAc,gBAAgB,CAAC;AAC/B,cAAc,iBAAiB,CAAC;AAChC,cAAc,iBAAiB,CAAC;AAChC,cAAc,kBAAkB,CAAC;AACjC,cAAc,iBAAiB,CAAC;AAChC,cAAc,gBAAgB,CAAC;AAC/B,cAAc,kBAAkB,CAAC;AACjC,cAAc,iBAAiB,CAAC;AAChC,cAAc,aAAa,CAAC;AAC5B,cAAc,aAAa,CAAC;AAC5B,cAAc,aAAa,CAAC;AAC5B,cAAc,oBAAoB,CAAC;AACnC,cAAc,mBAAmB,CAAC;AAClC,cAAc,mBAAmB,CAAC;AAClC,cAAc,cAAc,CAAC;AAC7B,cAAc,qBAAqB,CAAC;AACpC,cAAc,aAAa,CAAC;AAC5B,cAAc,aAAa,CAAC;AAC5B,cAAc,YAAY,CAAC;AAC3B,cAAc,mBAAmB,CAAC;AAClC,cAAc,eAAe,CAAC;AAC9B,cAAc,cAAc,CAAC;AAC7B,cAAc,aAAa,CAAC;AAC5B,cAAc,cAAc,CAAC;AAC7B,cAAc,wBAAwB,CAAC;AACvC,cAAc,uBAAuB,CAAC;AACtC,cAAc,oBAAoB,CAAC;AACnC,cAAc,SAAS,CAAC;AACxB,cAAc,SAAS,CAAC;AACxB,cAAc,eAAe,CAAC;AAC9B,cAAc,eAAe,CAAC;AAC9B,cAAc,oBAAoB,CAAC;AACnC,cAAc,eAAe,CAAC;AAC9B,cAAc,MAAM,CAAC;AACrB,cAAc,SAAS,CAAC;AACxB,cAAc,SAAS,CAAC;AACxB,cAAc,aAAa,CAAC;AAC5B,cAAc,WAAW,CAAC;AAC1B,cAAc,UAAU,CAAC;AACzB,cAAc,kBAAkB,CAAC;AACjC,cAAc,QAAQ,CAAC;AACvB,cAAc,OAAO,CAAC;AACtB,cAAc,OAAO,CAAC;AACtB,cAAc,MAAM,CAAC;AACrB,cAAc,OAAO,CAAC;AACtB,cAAc,aAAa,CAAC;AAC5B,cAAc,SAAS,CAAC;AACxB,cAAc,eAAe,CAAC;AAC9B,cAAc,SAAS,CAAC;AACxB,cAAc,iBAAiB,CAAC;AAChC,cAAc,iBAAiB,CAAC;AAChC,cAAc,iBAAiB,CAAC;AAChC,cAAc,YAAY,CAAC;AAC3B,cAAc,QAAQ,CAAC;AACvB,cAAc,OAAO,CAAC;AACtB,cAAc,YAAY,CAAC;AAC3B,cAAc,cAAc,CAAC"}
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/types/logic/index.ts"],"names":[],"mappings":"AAAA,cAAc,OAAO,CAAC;AACtB,cAAc,gBAAgB,CAAC;AAC/B,cAAc,gBAAgB,CAAC;AAC/B,cAAc,iBAAiB,CAAC;AAChC,cAAc,iBAAiB,CAAC;AAChC,cAAc,kBAAkB,CAAC;AACjC,cAAc,iBAAiB,CAAC;AAChC,cAAc,gBAAgB,CAAC;AAC/B,cAAc,kBAAkB,CAAC;AACjC,cAAc,iBAAiB,CAAC;AAChC,cAAc,aAAa,CAAC;AAC5B,cAAc,aAAa,CAAC;AAC5B,cAAc,aAAa,CAAC;AAC5B,cAAc,oBAAoB,CAAC;AACnC,cAAc,mBAAmB,CAAC;AAClC,cAAc,mBAAmB,CAAC;AAClC,cAAc,cAAc,CAAC;AAC7B,cAAc,qBAAqB,CAAC;AACpC,cAAc,aAAa,CAAC;AAC5B,cAAc,aAAa,CAAC;AAC5B,cAAc,YAAY,CAAC;AAC3B,cAAc,mBAAmB,CAAC;AAClC,cAAc,eAAe,CAAC;AAC9B,cAAc,cAAc,CAAC;AAC7B,cAAc,aAAa,CAAC;AAC5B,cAAc,cAAc,CAAC;AAC7B,cAAc,wBAAwB,CAAC;AACvC,cAAc,uBAAuB,CAAC;AACtC,cAAc,oBAAoB,CAAC;AACnC,cAAc,eAAe,CAAC;AAC9B,cAAc,gBAAgB,CAAC;AAC/B,cAAc,SAAS,CAAC;AACxB,cAAc,SAAS,CAAC;AACxB,cAAc,eAAe,CAAC;AAC9B,cAAc,eAAe,CAAC;AAC9B,cAAc,oBAAoB,CAAC;AACnC,cAAc,eAAe,CAAC;AAC9B,cAAc,MAAM,CAAC;AACrB,cAAc,SAAS,CAAC;AACxB,cAAc,SAAS,CAAC;AACxB,cAAc,aAAa,CAAC;AAC5B,cAAc,WAAW,CAAC;AAC1B,cAAc,UAAU,CAAC;AACzB,cAAc,kBAAkB,CAAC;AACjC,cAAc,QAAQ,CAAC;AACvB,cAAc,OAAO,CAAC;AACtB,cAAc,OAAO,CAAC;AACtB,cAAc,MAAM,CAAC;AACrB,cAAc,OAAO,CAAC;AACtB,cAAc,aAAa,CAAC;AAC5B,cAAc,SAAS,CAAC;AACxB,cAAc,eAAe,CAAC;AAC9B,cAAc,SAAS,CAAC;AACxB,cAAc,iBAAiB,CAAC;AAChC,cAAc,iBAAiB,CAAC;AAChC,cAAc,iBAAiB,CAAC;AAChC,cAAc,YAAY,CAAC;AAC3B,cAAc,uBAAuB,CAAC;AACtC,cAAc,QAAQ,CAAC;AACvB,cAAc,OAAO,CAAC;AACtB,cAAc,YAAY,CAAC;AAC3B,cAAc,cAAc,CAAC"}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Converts a union type to an intersection type
|
|
3
|
+
*
|
|
4
|
+
* @example
|
|
5
|
+
* ```typescript
|
|
6
|
+
* type A = { a: string }
|
|
7
|
+
* type B = { b: number }
|
|
8
|
+
* type Union = A | B
|
|
9
|
+
* type Intersection = UnionToIntersection<Union> // { a: string } & { b: number }
|
|
10
|
+
* ```
|
|
11
|
+
*/
|
|
12
|
+
export type UnionToIntersection<U> = (U extends unknown ? (k: U) => void : never) extends (k: infer I) => void ? I : never;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"unionToIntersection.js","sourceRoot":"","sources":["../../../src/types/logic/unionToIntersection.ts"],"names":[],"mappings":""}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/types/object/index.ts"],"names":[],"mappings":"AAAA,cAAc,YAAY,CAAC;AAC3B,cAAc,eAAe,CAAC"}
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/types/object/index.ts"],"names":[],"mappings":"AAAA,cAAc,YAAY,CAAC;AAC3B,cAAc,eAAe,CAAC;AAC9B,cAAc,sBAAsB,CAAC"}
|
|
@@ -1 +1,13 @@
|
|
|
1
|
-
|
|
1
|
+
import type { PickDeepKey } from "./pickDeepKey";
|
|
2
|
+
import type { UnionToIntersection } from "../logic/unionToIntersection";
|
|
3
|
+
type GetValueAtPath<T, P extends string> = P extends `${infer Key}.${infer Rest}` ? Key extends keyof T ? T[Key] extends object ? GetValueAtPath<T[Key], Rest> : never : never : P extends keyof T ? T[P] : never;
|
|
4
|
+
type ConstructNestedObject<P extends string, V> = P extends `${infer Key}.${infer Rest}` ? {
|
|
5
|
+
[K in Key]: ConstructNestedObject<Rest, V>;
|
|
6
|
+
} : {
|
|
7
|
+
[K in P]: V;
|
|
8
|
+
};
|
|
9
|
+
type ProcessKeys<T extends object, K extends readonly PickDeepKey<T>[]> = {
|
|
10
|
+
[I in keyof K]: K[I] extends string ? ConstructNestedObject<K[I], GetValueAtPath<T, K[I]>> : never;
|
|
11
|
+
}[number];
|
|
12
|
+
export type PickDeep<T extends object, K extends readonly PickDeepKey<T>[]> = UnionToIntersection<ProcessKeys<T, K>>;
|
|
13
|
+
export {};
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import type { UnionToIntersection } from "../logic/unionToIntersection";
|
|
2
|
+
/**
|
|
3
|
+
* Extract the value type from the first level of an object
|
|
4
|
+
*
|
|
5
|
+
* @example
|
|
6
|
+
* type Input = { a: { b: { c: {} } } }
|
|
7
|
+
* type Output = ShallowObjectValue<Input> // { b: { c: {} } }
|
|
8
|
+
*/
|
|
9
|
+
export type ShallowObjectValue<T> = T extends Record<PropertyKey, infer U> ? UnionToIntersection<U> : never;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"shallowObjectValue.js","sourceRoot":"","sources":["../../../src/types/object/shallowObjectValue.ts"],"names":[],"mappings":""}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import type { FormatValue } from "./formatValue";
|
|
2
|
+
/**
|
|
3
|
+
* Data structure for formatString input.
|
|
4
|
+
*
|
|
5
|
+
* Can be either an object for named placeholders or an array for indexed placeholders.
|
|
6
|
+
*
|
|
7
|
+
* @example
|
|
8
|
+
* // Object for named placeholders
|
|
9
|
+
* const namedData: FormatData = { name: "Alice", age: 25 };
|
|
10
|
+
* formatString("Hello {name}, age {age}", namedData);
|
|
11
|
+
*
|
|
12
|
+
* @example
|
|
13
|
+
* // Array for indexed placeholders
|
|
14
|
+
* const indexedData: FormatData = ["Alice", 25];
|
|
15
|
+
* formatString("Hello {0}, age {1}", ...indexedData);
|
|
16
|
+
*/
|
|
17
|
+
export type FormatData = Record<string, unknown> | FormatValue[];
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"formatData.js","sourceRoot":"","sources":["../../../../src/types/string/formatString/formatData.ts"],"names":[],"mappings":""}
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import type { Formatter } from "./formatter";
|
|
2
|
+
/**
|
|
3
|
+
* Configuration options for formatString.
|
|
4
|
+
*
|
|
5
|
+
* @property formatters - Custom formatter functions to extend or override built-in formatters
|
|
6
|
+
* @property locale - Default locale for built-in formatters (currently unused but reserved)
|
|
7
|
+
*
|
|
8
|
+
* @example
|
|
9
|
+
* const options: FormatOptions = {
|
|
10
|
+
* formatters: {
|
|
11
|
+
* reverse: (value) => String(value).split('').reverse().join(''),
|
|
12
|
+
* shout: (value) => `${String(value).toUpperCase()}!`
|
|
13
|
+
* }
|
|
14
|
+
* };
|
|
15
|
+
* formatString("{text:reverse} {text:shout}", { text: "hello" }, options);
|
|
16
|
+
* // → "olleh HELLO!"
|
|
17
|
+
*/
|
|
18
|
+
export interface FormatOptions {
|
|
19
|
+
formatters?: Record<string, Formatter>;
|
|
20
|
+
locale?: string;
|
|
21
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"formatOptions.js","sourceRoot":"","sources":["../../../../src/types/string/formatString/formatOptions.ts"],"names":[],"mappings":""}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"formatString.js","sourceRoot":"","sources":["../../../../src/types/string/formatString/formatString.ts"],"names":[],"mappings":"AAAA,cAAc,cAAc,CAAC;AAC7B,cAAc,iBAAiB,CAAC;AAChC,cAAc,aAAa,CAAC;AAC5B,cAAc,eAAe,CAAC"}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Valid value types that can be passed to formatString.
|
|
3
|
+
*
|
|
4
|
+
* Includes primitives, objects, arrays, and null/undefined values.
|
|
5
|
+
* Objects and arrays are typically used in indexed mode as placeholder values.
|
|
6
|
+
*
|
|
7
|
+
* @example
|
|
8
|
+
* // Primitive values
|
|
9
|
+
* formatString("{0} {1}", "hello", 42) // string, number
|
|
10
|
+
*
|
|
11
|
+
* @example
|
|
12
|
+
* // Complex values
|
|
13
|
+
* formatString("{0} {1}", { key: "value" }, [1, 2, 3]) // object, array
|
|
14
|
+
*/
|
|
15
|
+
export type FormatValue = string | number | boolean | Date | null | undefined | Record<string, unknown> | unknown[];
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"formatValue.js","sourceRoot":"","sources":["../../../../src/types/string/formatString/formatValue.ts"],"names":[],"mappings":""}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Function type for formatString formatter functions.
|
|
3
|
+
*
|
|
4
|
+
* @param value - The value to be formatted
|
|
5
|
+
* @param arguments_ - Additional string arguments passed to the formatter
|
|
6
|
+
* @returns Formatted string representation of the value
|
|
7
|
+
*
|
|
8
|
+
* @example
|
|
9
|
+
* const upperFormatter: Formatter = (value) => String(value).toUpperCase();
|
|
10
|
+
* const padFormatter: Formatter = (value, length = "2", char = "0") =>
|
|
11
|
+
* String(value).padStart(Number(length), char);
|
|
12
|
+
*/
|
|
13
|
+
export type Formatter = (value: unknown, ...arguments_: string[]) => string;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"formatter.js","sourceRoot":"","sources":["../../../../src/types/string/formatString/formatter.ts"],"names":[],"mappings":""}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../src/types/string/formatString/index.ts"],"names":[],"mappings":"AAAA,cAAc,cAAc,CAAC;AAC7B,cAAc,eAAe,CAAC;AAC9B,cAAc,aAAa,CAAC;AAC5B,cAAc,gBAAgB,CAAC;AAC/B,cAAc,iBAAiB,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from "./formatString";
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/types/string/index.ts"],"names":[],"mappings":"AAAA,cAAc,gBAAgB,CAAC"}
|
package/package.json
CHANGED
|
@@ -3,37 +3,37 @@
|
|
|
3
3
|
"bugs": {
|
|
4
4
|
"url": "https://github.com/riya-amemiya/UMT/issues"
|
|
5
5
|
},
|
|
6
|
-
"description": "
|
|
6
|
+
"description": "UMT Main Package is written in TypeScript and is a collection of useful functions for various tasks.",
|
|
7
7
|
"devDependencies": {
|
|
8
|
-
"@babel/cli": "
|
|
9
|
-
"@babel/core": "
|
|
10
|
-
"@babel/preset-env": "
|
|
11
|
-
"@babel/preset-typescript": "
|
|
12
|
-
"@biomejs/biome": "1.
|
|
13
|
-
"@swc/core": "
|
|
14
|
-
"@swc/jest": "
|
|
15
|
-
"@types/bun": "
|
|
16
|
-
"@types/jest": "
|
|
17
|
-
"@types/lodash": "
|
|
18
|
-
"@types/node": "
|
|
19
|
-
"@typescript-eslint/eslint-plugin": "
|
|
20
|
-
"@typescript-eslint/parser": "
|
|
21
|
-
"bun-types": "
|
|
22
|
-
"dependency-cruiser": "
|
|
23
|
-
"es-toolkit": "
|
|
24
|
-
"eslint": "
|
|
25
|
-
"eslint-plugin-import": "
|
|
26
|
-
"eslint-plugin-unicorn": "
|
|
27
|
-
"fast-sort": "
|
|
28
|
-
"gh-pages": "
|
|
29
|
-
"jest": "
|
|
30
|
-
"lodash": "
|
|
31
|
-
"mitata": "
|
|
32
|
-
"ts-jest": "
|
|
33
|
-
"ts-node": "
|
|
34
|
-
"tsc-alias": "
|
|
35
|
-
"typedoc": "
|
|
36
|
-
"typescript": "
|
|
8
|
+
"@babel/cli": "7.28.0",
|
|
9
|
+
"@babel/core": "7.28.0",
|
|
10
|
+
"@babel/preset-env": "7.28.0",
|
|
11
|
+
"@babel/preset-typescript": "7.27.1",
|
|
12
|
+
"@biomejs/biome": "2.1.2",
|
|
13
|
+
"@swc/core": "1.13.0",
|
|
14
|
+
"@swc/jest": "0.2.39",
|
|
15
|
+
"@types/bun": "1.2.18",
|
|
16
|
+
"@types/jest": "30.0.0",
|
|
17
|
+
"@types/lodash": "4.17.20",
|
|
18
|
+
"@types/node": "24.0.14",
|
|
19
|
+
"@typescript-eslint/eslint-plugin": "8.37.0",
|
|
20
|
+
"@typescript-eslint/parser": "8.37.0",
|
|
21
|
+
"bun-types": "1.2.18",
|
|
22
|
+
"dependency-cruiser": "16.10.4",
|
|
23
|
+
"es-toolkit": "1.39.7",
|
|
24
|
+
"eslint": "9.31.0",
|
|
25
|
+
"eslint-plugin-import": "2.32.0",
|
|
26
|
+
"eslint-plugin-unicorn": "59.0.1",
|
|
27
|
+
"fast-sort": "3.4.1",
|
|
28
|
+
"gh-pages": "6.3.0",
|
|
29
|
+
"jest": "30.0.4",
|
|
30
|
+
"lodash": "4.17.21",
|
|
31
|
+
"mitata": "1.0.34",
|
|
32
|
+
"ts-jest": "29.4.0",
|
|
33
|
+
"ts-node": "10.9.2",
|
|
34
|
+
"tsc-alias": "1.8.16",
|
|
35
|
+
"typedoc": "0.28.7",
|
|
36
|
+
"typescript": "5.8.3"
|
|
37
37
|
},
|
|
38
38
|
"directories": {
|
|
39
39
|
"doc": "doc",
|
|
@@ -57,24 +57,23 @@
|
|
|
57
57
|
},
|
|
58
58
|
"scripts": {
|
|
59
59
|
"build": "tsc && tsc-alias -p tsconfig.json",
|
|
60
|
-
"build:cjs": "tsc -p tsconfig.cjs.json &&
|
|
60
|
+
"build:cjs": "tsc -p tsconfig.cjs.json && bun run cjs.build.mjs && cp LICENSE common-module/LICENSE && cp README.md common-module/README.md && cp .npmignore common-module/.npmignore",
|
|
61
61
|
"build:babel": "babel src --extensions '.ts' --out-dir module/es5 && tsc --emitDeclarationOnly --outDir module/es5",
|
|
62
62
|
"build:cjs:babel": "babel src --extensions '.ts' --out-dir common-module/module/es5 && tsc --emitDeclarationOnly --outDir common-module/module/es5",
|
|
63
|
-
"build:full": "
|
|
64
|
-
"build:clean": "rm -rf module &&
|
|
65
|
-
"build:clean:full": "rm -rf module && rm -rf common-module &&
|
|
66
|
-
"clean-build": "rm -rf module &&
|
|
67
|
-
"deploy": "
|
|
63
|
+
"build:full": "bun run build && bun run build:cjs && bun run build:babel && bun run build:cjs:babel",
|
|
64
|
+
"build:clean": "rm -rf module && bun run build",
|
|
65
|
+
"build:clean:full": "rm -rf module && rm -rf common-module && bun run build:full",
|
|
66
|
+
"clean-build": "rm -rf module && bun run build",
|
|
67
|
+
"deploy": "bun run typedoc && gh-pages -d doc",
|
|
68
68
|
"eslint": "eslint src",
|
|
69
69
|
"format": "biome format . --write",
|
|
70
|
-
"lint": "
|
|
71
|
-
"lint:ci": "
|
|
70
|
+
"lint": "bun run eslint --fix && biome check . --write && tsc",
|
|
71
|
+
"lint:ci": "bun run eslint && biome ci . && tsc",
|
|
72
72
|
"test": "jest",
|
|
73
73
|
"test-debug": "cd test && tsc",
|
|
74
|
-
"ts-node": "
|
|
74
|
+
"ts-node": "bun run build && ts-node --project tmp/tsconfig.json tmp/src/index.ts"
|
|
75
75
|
},
|
|
76
76
|
"type": "module",
|
|
77
77
|
"types": "module/index.d.js",
|
|
78
|
-
"version": "2.
|
|
79
|
-
"packageManager": "yarn@1.22.22"
|
|
78
|
+
"version": "2.7.0"
|
|
80
79
|
}
|
|
@@ -1,13 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Replaces placeholders in a template string with specified values.
|
|
3
|
-
* Placeholders are in the format {0}, {1}, {2}... and corresponding values are passed as an array.
|
|
4
|
-
*
|
|
5
|
-
* @param template - Template string containing placeholders
|
|
6
|
-
* @param values - Array of values to replace the placeholders in the template
|
|
7
|
-
* @returns String with placeholders replaced with values
|
|
8
|
-
*
|
|
9
|
-
* @example
|
|
10
|
-
* // Returns "Hello, World!"
|
|
11
|
-
* formatString("Hello, {0}!", "World");
|
|
12
|
-
*/
|
|
13
|
-
export declare const formatString: (template: string, ...values: unknown[]) => string;
|
|
@@ -1,18 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Replaces placeholders in a template string with specified values.
|
|
3
|
-
* Placeholders are in the format {0}, {1}, {2}... and corresponding values are passed as an array.
|
|
4
|
-
*
|
|
5
|
-
* @param template - Template string containing placeholders
|
|
6
|
-
* @param values - Array of values to replace the placeholders in the template
|
|
7
|
-
* @returns String with placeholders replaced with values
|
|
8
|
-
*
|
|
9
|
-
* @example
|
|
10
|
-
* // Returns "Hello, World!"
|
|
11
|
-
* formatString("Hello, {0}!", "World");
|
|
12
|
-
*/
|
|
13
|
-
export const formatString = (template, ...values) => {
|
|
14
|
-
return template.replaceAll(/{(\d+)}/g, (match, index) => {
|
|
15
|
-
return values[index] === undefined ? match : String(values[index]);
|
|
16
|
-
});
|
|
17
|
-
};
|
|
18
|
-
//# sourceMappingURL=formatString.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"formatString.js","sourceRoot":"","sources":["../../src/String/formatString.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;GAWG;AACH,MAAM,CAAC,MAAM,YAAY,GAAG,CAAC,QAAgB,EAAE,GAAG,MAAiB,EAAE,EAAE;IACrE,OAAO,QAAQ,CAAC,UAAU,CAAC,UAAU,EAAE,CAAC,KAAK,EAAE,KAAK,EAAE,EAAE;QACtD,OAAO,MAAM,CAAC,KAAK,CAAC,KAAK,SAAS,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,MAAM,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC,CAAC;IACrE,CAAC,CAAC,CAAC;AACL,CAAC,CAAC"}
|
|
@@ -1,13 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Replaces placeholders in a template string with specified values.
|
|
3
|
-
* Placeholders are in the format {0}, {1}, {2}... and corresponding values are passed as an array.
|
|
4
|
-
*
|
|
5
|
-
* @param template - Template string containing placeholders
|
|
6
|
-
* @param values - Array of values to replace the placeholders in the template
|
|
7
|
-
* @returns String with placeholders replaced with values
|
|
8
|
-
*
|
|
9
|
-
* @example
|
|
10
|
-
* // Returns "Hello, World!"
|
|
11
|
-
* formatString("Hello, {0}!", "World");
|
|
12
|
-
*/
|
|
13
|
-
export declare const formatString: (template: string, ...values: unknown[]) => string;
|
|
@@ -1,26 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
Object.defineProperty(exports, "__esModule", {
|
|
4
|
-
value: true
|
|
5
|
-
});
|
|
6
|
-
exports.formatString = void 0;
|
|
7
|
-
/**
|
|
8
|
-
* Replaces placeholders in a template string with specified values.
|
|
9
|
-
* Placeholders are in the format {0}, {1}, {2}... and corresponding values are passed as an array.
|
|
10
|
-
*
|
|
11
|
-
* @param template - Template string containing placeholders
|
|
12
|
-
* @param values - Array of values to replace the placeholders in the template
|
|
13
|
-
* @returns String with placeholders replaced with values
|
|
14
|
-
*
|
|
15
|
-
* @example
|
|
16
|
-
* // Returns "Hello, World!"
|
|
17
|
-
* formatString("Hello, {0}!", "World");
|
|
18
|
-
*/
|
|
19
|
-
var formatString = exports.formatString = function formatString(template) {
|
|
20
|
-
for (var _len = arguments.length, values = new Array(_len > 1 ? _len - 1 : 0), _key = 1; _key < _len; _key++) {
|
|
21
|
-
values[_key - 1] = arguments[_key];
|
|
22
|
-
}
|
|
23
|
-
return template.replaceAll(/{(\d+)}/g, function (match, index) {
|
|
24
|
-
return values[index] === undefined ? match : String(values[index]);
|
|
25
|
-
});
|
|
26
|
-
};
|