umt 2.12.2 → 2.13.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 +60 -0
- package/module/Array/arraysJoin.js +1 -1
- package/module/Array/arraysJoin.js.map +1 -1
- package/module/Array/chunk.js +1 -2
- package/module/Array/chunk.js.map +1 -1
- package/module/Array/generateNumberArray.js +13 -3
- package/module/Array/generateNumberArray.js.map +1 -1
- package/module/Array/getArraysDiff.js +5 -1
- package/module/Array/getArraysDiff.js.map +1 -1
- package/module/Array/mergeSort.js +45 -18
- package/module/Array/mergeSort.js.map +1 -1
- package/module/Array/pop.js +2 -1
- package/module/Array/pop.js.map +1 -1
- package/module/Array/randomSelect.js +8 -0
- package/module/Array/randomSelect.js.map +1 -1
- package/module/Array/sortingHelpers/rangeValidator.js +3 -2
- package/module/Array/sortingHelpers/rangeValidator.js.map +1 -1
- package/module/Array/timSort.js +25 -23
- package/module/Array/timSort.js.map +1 -1
- package/module/Array/ultraNumberSort.js +206 -133
- package/module/Array/ultraNumberSort.js.map +1 -1
- package/module/Async/defer.d.ts +18 -0
- package/module/Async/defer.js +19 -0
- package/module/Async/defer.js.map +1 -0
- package/module/Async/index.d.ts +4 -0
- package/module/Async/index.js +5 -0
- package/module/Async/index.js.map +1 -0
- package/module/Async/parallel.d.ts +10 -0
- package/module/Async/parallel.js +44 -0
- package/module/Async/parallel.js.map +1 -0
- package/module/Async/sleep.d.ts +8 -0
- package/module/Async/sleep.js +11 -0
- package/module/Async/sleep.js.map +1 -0
- package/module/Async/timeout.d.ts +10 -0
- package/module/Async/timeout.js +22 -0
- package/module/Async/timeout.js.map +1 -0
- package/module/Color/cmykToRgba.js +6 -7
- package/module/Color/cmykToRgba.js.map +1 -1
- package/module/Color/hexaToRgba.js +1 -8
- package/module/Color/hexaToRgba.js.map +1 -1
- package/module/Color/hslaToRgba.d.ts +0 -1
- package/module/Color/hslaToRgba.js +7 -22
- package/module/Color/hslaToRgba.js.map +1 -1
- package/module/Color/rgbaToCmyk.js +0 -11
- package/module/Color/rgbaToCmyk.js.map +1 -1
- package/module/Color/rgbaToHexA.js +2 -15
- package/module/Color/rgbaToHexA.js.map +1 -1
- package/module/Color/rgbaToHsla.d.ts +0 -1
- package/module/Color/rgbaToHsla.js +0 -12
- package/module/Color/rgbaToHsla.js.map +1 -1
- package/module/Crypto/constants.d.ts +2 -0
- package/module/Crypto/constants.js +3 -0
- package/module/Crypto/constants.js.map +1 -0
- package/module/Crypto/decodeBase32.js +2 -4
- package/module/Crypto/decodeBase32.js.map +1 -1
- package/module/Crypto/decodeBase58.js +2 -4
- package/module/Crypto/decodeBase58.js.map +1 -1
- package/module/Crypto/encodeBase32.js +2 -1
- package/module/Crypto/encodeBase32.js.map +1 -1
- package/module/Crypto/encodeBase58.js +2 -1
- package/module/Crypto/encodeBase58.js.map +1 -1
- package/module/DataStructure/index.d.ts +2 -0
- package/module/DataStructure/index.js +2 -0
- package/module/DataStructure/index.js.map +1 -1
- package/module/DataStructure/lruCache.d.ts +139 -0
- package/module/DataStructure/lruCache.js +172 -0
- package/module/DataStructure/lruCache.js.map +1 -0
- package/module/DataStructure/ttlCache.d.ts +139 -0
- package/module/DataStructure/ttlCache.js +172 -0
- package/module/DataStructure/ttlCache.js.map +1 -0
- package/module/Error/flatMapResult.d.ts +23 -0
- package/module/Error/flatMapResult.js +28 -0
- package/module/Error/flatMapResult.js.map +1 -0
- package/module/Error/index.d.ts +3 -0
- package/module/Error/index.js +3 -0
- package/module/Error/index.js.map +1 -1
- package/module/Error/mapResult.d.ts +21 -0
- package/module/Error/mapResult.js +27 -0
- package/module/Error/mapResult.js.map +1 -0
- package/module/Error/matchResult.d.ts +25 -0
- package/module/Error/matchResult.js +27 -0
- package/module/Error/matchResult.js.map +1 -0
- package/module/Error/safeExecute.d.ts +16 -3
- package/module/Error/safeExecute.js +5 -2
- package/module/Error/safeExecute.js.map +1 -1
- package/module/Function/debounce.d.ts +38 -0
- package/module/Function/debounce.js +67 -0
- package/module/Function/debounce.js.map +1 -0
- package/module/Function/index.d.ts +4 -0
- package/module/Function/index.js +4 -0
- package/module/Function/index.js.map +1 -1
- package/module/Function/memoize.d.ts +36 -0
- package/module/Function/memoize.js +54 -0
- package/module/Function/memoize.js.map +1 -0
- package/module/Function/once.d.ts +18 -0
- package/module/Function/once.js +29 -0
- package/module/Function/once.js.map +1 -0
- package/module/Function/throttle.d.ts +25 -0
- package/module/Function/throttle.js +55 -0
- package/module/Function/throttle.js.map +1 -0
- package/module/IP/cidrToLong.d.ts +0 -1
- package/module/IP/cidrToLong.js +0 -4
- package/module/IP/cidrToLong.js.map +1 -1
- package/module/IP/cidrToSubnetMask.d.ts +0 -1
- package/module/IP/cidrToSubnetMask.js +0 -1
- package/module/IP/cidrToSubnetMask.js.map +1 -1
- package/module/IP/getNetworkAddress.d.ts +0 -1
- package/module/IP/getNetworkAddress.js +2 -32
- package/module/IP/getNetworkAddress.js.map +1 -1
- package/module/IP/ipToBinaryString.d.ts +0 -1
- package/module/IP/ipToBinaryString.js +2 -25
- package/module/IP/ipToBinaryString.js.map +1 -1
- package/module/IP/ipToLong.d.ts +0 -1
- package/module/IP/ipToLong.js +0 -1
- package/module/IP/ipToLong.js.map +1 -1
- package/module/IP/isInRange.d.ts +0 -1
- package/module/IP/isInRange.js +5 -28
- package/module/IP/isInRange.js.map +1 -1
- package/module/IP/isPrivateIp.d.ts +0 -1
- package/module/IP/isPrivateIp.js +1 -10
- package/module/IP/isPrivateIp.js.map +1 -1
- package/module/IP/longToIp.d.ts +0 -1
- package/module/IP/longToIp.js +0 -8
- package/module/IP/longToIp.js.map +1 -1
- package/module/IP/subnetMaskToCidr.d.ts +0 -1
- package/module/IP/subnetMaskToCidr.js +2 -23
- package/module/IP/subnetMaskToCidr.js.map +1 -1
- package/module/Iterator/index.d.ts +3 -0
- package/module/Iterator/index.js +4 -0
- package/module/Iterator/index.js.map +1 -0
- package/module/Iterator/lazyFilter.d.ts +10 -0
- package/module/Iterator/lazyFilter.js +19 -0
- package/module/Iterator/lazyFilter.js.map +1 -0
- package/module/Iterator/lazyMap.d.ts +10 -0
- package/module/Iterator/lazyMap.js +17 -0
- package/module/Iterator/lazyMap.js.map +1 -0
- package/module/Iterator/lazyTake.d.ts +10 -0
- package/module/Iterator/lazyTake.js +20 -0
- package/module/Iterator/lazyTake.js.map +1 -0
- package/module/Math/addition.js +20 -4
- package/module/Math/addition.js.map +1 -1
- package/module/Math/average.js +3 -3
- package/module/Math/average.js.map +1 -1
- package/module/Math/bitwise.js +1 -1
- package/module/Math/bitwise.js.map +1 -1
- package/module/Math/calculator/core.js +2 -1
- package/module/Math/calculator/core.js.map +1 -1
- package/module/Math/calculator/literalExpression.js +1 -1
- package/module/Math/clamp.d.ts +16 -0
- package/module/Math/clamp.js +19 -0
- package/module/Math/clamp.js.map +1 -0
- package/module/Math/correlationCoefficient.js +0 -3
- package/module/Math/correlationCoefficient.js.map +1 -1
- package/module/Math/inRange.d.ts +19 -0
- package/module/Math/inRange.js +24 -0
- package/module/Math/inRange.js.map +1 -0
- 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/median.js +2 -2
- package/module/Math/median.js.map +1 -1
- package/module/Math/nCr.js +2 -4
- package/module/Math/nCr.js.map +1 -1
- package/module/Math/percentile.js +2 -5
- package/module/Math/percentile.js.map +1 -1
- package/module/Math/primeFactorization.js +1 -1
- package/module/Math/primeFactorization.js.map +1 -1
- package/module/Math/sumPrecise.d.ts +14 -0
- package/module/Math/sumPrecise.js +27 -0
- package/module/Math/sumPrecise.js.map +1 -0
- package/module/Math/uuidv7.js +56 -22
- package/module/Math/uuidv7.js.map +1 -1
- package/module/Number/formatNumber.d.ts +42 -0
- package/module/Number/formatNumber.js +44 -0
- package/module/Number/formatNumber.js.map +1 -0
- package/module/Number/index.d.ts +3 -0
- package/module/Number/index.js +4 -0
- package/module/Number/index.js.map +1 -0
- package/module/Number/toOrdinal.d.ts +20 -0
- package/module/Number/toOrdinal.js +37 -0
- package/module/Number/toOrdinal.js.map +1 -0
- package/module/Number/toPercentage.d.ts +20 -0
- package/module/Number/toPercentage.js +27 -0
- package/module/Number/toPercentage.js.map +1 -0
- package/module/Object/deepClone.d.ts +15 -0
- package/module/Object/deepClone.js +62 -0
- package/module/Object/deepClone.js.map +1 -0
- package/module/Object/getObjectsCommon.d.ts +23 -0
- package/module/Object/getObjectsCommon.js +60 -0
- package/module/Object/getObjectsCommon.js.map +1 -0
- package/module/Object/getObjectsDiff.d.ts +25 -0
- package/module/Object/getObjectsDiff.js +79 -0
- package/module/Object/getObjectsDiff.js.map +1 -0
- package/module/Object/index.d.ts +6 -0
- package/module/Object/index.js +6 -0
- package/module/Object/index.js.map +1 -1
- package/module/Object/isPlainObject.d.ts +16 -0
- package/module/Object/isPlainObject.js +32 -0
- package/module/Object/isPlainObject.js.map +1 -0
- package/module/Object/mapKeys.d.ts +15 -0
- package/module/Object/mapKeys.js +28 -0
- package/module/Object/mapKeys.js.map +1 -0
- package/module/Object/mapValues.d.ts +15 -0
- package/module/Object/mapValues.js +27 -0
- package/module/Object/mapValues.js.map +1 -0
- package/module/Object/mergeDeep.js +4 -9
- package/module/Object/mergeDeep.js.map +1 -1
- package/module/Object/omit.d.ts +1 -1
- package/module/Object/omit.js.map +1 -1
- package/module/Object/pickDeep.js +6 -1
- package/module/Object/pickDeep.js.map +1 -1
- package/module/Predicate/every.d.ts +14 -0
- package/module/Predicate/every.js +22 -0
- package/module/Predicate/every.js.map +1 -0
- package/module/Predicate/index.d.ts +6 -0
- package/module/Predicate/index.js +7 -0
- package/module/Predicate/index.js.map +1 -0
- package/module/Predicate/isNotNullish.d.ts +11 -0
- package/module/Predicate/isNotNullish.js +12 -0
- package/module/Predicate/isNotNullish.js.map +1 -0
- package/module/Predicate/isNullish.d.ts +11 -0
- package/module/Predicate/isNullish.js +12 -0
- package/module/Predicate/isNullish.js.map +1 -0
- package/module/Predicate/matches.d.ts +11 -0
- package/module/Predicate/matches.js +20 -0
- package/module/Predicate/matches.js.map +1 -0
- package/module/Predicate/not.d.ts +10 -0
- package/module/Predicate/not.js +11 -0
- package/module/Predicate/not.js.map +1 -0
- package/module/Predicate/some.d.ts +15 -0
- package/module/Predicate/some.js +23 -0
- package/module/Predicate/some.js.map +1 -0
- package/module/String/camelCase.js +2 -2
- package/module/String/camelCase.js.map +1 -1
- package/module/String/escapeHtml.js +1 -1
- package/module/String/formatString/getValue.js +1 -1
- package/module/String/formatString/getValue.js.map +1 -1
- package/module/String/fromBase64.d.ts +0 -1
- package/module/String/fromBase64.js +1 -9
- package/module/String/fromBase64.js.map +1 -1
- package/module/String/fuzzySearch.js +74 -6
- package/module/String/fuzzySearch.js.map +1 -1
- package/module/String/kebabCase.js +1 -1
- package/module/String/kebabCase.js.map +1 -1
- package/module/String/levenshteinDistance.js +1 -2
- package/module/String/levenshteinDistance.js.map +1 -1
- package/module/String/randomString.js +23 -2
- package/module/String/randomString.js.map +1 -1
- package/module/String/reverseString.js +1 -1
- package/module/String/reverseString.js.map +1 -1
- package/module/String/slugify.js +1 -1
- package/module/String/toHalfWidth.js +2 -2
- package/module/String/toHalfWidth.js.map +1 -1
- package/module/String/truncate.js +0 -3
- package/module/String/truncate.js.map +1 -1
- package/module/String/unescapeHtml.js +1 -1
- package/module/String/unescapeHtml.js.map +1 -1
- package/module/Time/convertTime.js +4 -3
- package/module/Time/convertTime.js.map +1 -1
- package/module/Tool/escapeRegExp.d.ts +8 -0
- package/module/Tool/escapeRegExp.js +11 -0
- package/module/Tool/escapeRegExp.js.map +1 -0
- package/module/Tool/index.d.ts +1 -0
- package/module/Tool/index.js +1 -0
- package/module/Tool/index.js.map +1 -1
- package/module/URL/buildUrl.d.ts +17 -0
- package/module/URL/buildUrl.js +24 -0
- package/module/URL/buildUrl.js.map +1 -0
- package/module/URL/index.d.ts +4 -0
- package/module/URL/index.js +5 -0
- package/module/URL/index.js.map +1 -0
- package/module/URL/isAbsoluteUrl.d.ts +20 -0
- package/module/URL/isAbsoluteUrl.js +23 -0
- package/module/URL/isAbsoluteUrl.js.map +1 -0
- package/module/URL/joinPath.d.ts +24 -0
- package/module/URL/joinPath.js +43 -0
- package/module/URL/joinPath.js.map +1 -0
- package/module/URL/parseQueryString.d.ts +22 -0
- package/module/URL/parseQueryString.js +34 -0
- package/module/URL/parseQueryString.js.map +1 -0
- package/module/Validate/parseEmail.js +5 -5
- package/module/Validate/parseEmail.js.map +1 -1
- package/module/es5/Array/arraysJoin.js +1 -1
- package/module/es5/Array/chunk.js +3 -2
- package/module/es5/Array/generateNumberArray.js +21 -3
- package/module/es5/Array/getArraysDiff.js +5 -3
- package/module/es5/Array/mergeSort.js +51 -19
- package/module/es5/Array/pop.js +2 -7
- package/module/es5/Array/randomSelect.js +8 -0
- package/module/es5/Array/sortingHelpers/rangeValidator.js +3 -2
- package/module/es5/Array/timSort.js +25 -23
- package/module/es5/Array/ultraNumberSort.js +221 -207
- package/module/es5/Async/defer.d.ts +18 -0
- package/module/es5/Async/defer.js +32 -0
- package/module/es5/Async/index.d.ts +4 -0
- package/module/es5/Async/index.js +49 -0
- package/module/es5/Async/parallel.d.ts +10 -0
- package/module/es5/Async/parallel.js +48 -0
- package/module/es5/Async/sleep.d.ts +8 -0
- package/module/es5/Async/sleep.js +18 -0
- package/module/es5/Async/timeout.d.ts +10 -0
- package/module/es5/Async/timeout.js +29 -0
- package/module/es5/Color/cmykToRgba.js +6 -7
- package/module/es5/Color/hexaToRgba.js +7 -5
- package/module/es5/Color/hslaToRgba.d.ts +0 -1
- package/module/es5/Color/hslaToRgba.js +7 -22
- package/module/es5/Color/rgbaToCmyk.js +0 -4
- package/module/es5/Color/rgbaToHexA.js +2 -6
- package/module/es5/Color/rgbaToHsla.d.ts +0 -1
- package/module/es5/Color/rgbaToHsla.js +0 -5
- package/module/es5/Crypto/constants.d.ts +2 -0
- package/module/es5/Crypto/constants.js +8 -0
- package/module/es5/Crypto/decodeBase32.js +2 -4
- package/module/es5/Crypto/decodeBase58.js +2 -4
- package/module/es5/Crypto/encodeBase32.js +2 -1
- package/module/es5/Crypto/encodeBase58.js +2 -1
- package/module/es5/DataStructure/index.d.ts +2 -0
- package/module/es5/DataStructure/index.js +22 -0
- package/module/es5/DataStructure/lruCache.d.ts +139 -0
- package/module/es5/DataStructure/lruCache.js +205 -0
- package/module/es5/DataStructure/ttlCache.d.ts +139 -0
- package/module/es5/DataStructure/ttlCache.js +211 -0
- package/module/es5/Error/flatMapResult.d.ts +23 -0
- package/module/es5/Error/flatMapResult.js +33 -0
- package/module/es5/Error/index.d.ts +3 -0
- package/module/es5/Error/index.js +33 -0
- package/module/es5/Error/mapResult.d.ts +21 -0
- package/module/es5/Error/mapResult.js +32 -0
- package/module/es5/Error/matchResult.d.ts +25 -0
- package/module/es5/Error/matchResult.js +32 -0
- package/module/es5/Error/safeExecute.d.ts +16 -3
- package/module/es5/Error/safeExecute.js +3 -3
- package/module/es5/Function/debounce.d.ts +38 -0
- package/module/es5/Function/debounce.js +88 -0
- package/module/es5/Function/index.d.ts +4 -0
- package/module/es5/Function/index.js +44 -0
- package/module/es5/Function/memoize.d.ts +36 -0
- package/module/es5/Function/memoize.js +73 -0
- package/module/es5/Function/once.d.ts +18 -0
- package/module/es5/Function/once.js +37 -0
- package/module/es5/Function/throttle.d.ts +25 -0
- package/module/es5/Function/throttle.js +69 -0
- package/module/es5/IP/cidrToLong.d.ts +0 -1
- package/module/es5/IP/cidrToLong.js +0 -4
- package/module/es5/IP/cidrToSubnetMask.d.ts +0 -1
- package/module/es5/IP/cidrToSubnetMask.js +0 -1
- package/module/es5/IP/getNetworkAddress.d.ts +0 -1
- package/module/es5/IP/getNetworkAddress.js +2 -31
- package/module/es5/IP/ipToBinaryString.d.ts +0 -1
- package/module/es5/IP/ipToBinaryString.js +1 -40
- package/module/es5/IP/ipToLong.d.ts +0 -1
- package/module/es5/IP/ipToLong.js +0 -1
- package/module/es5/IP/isInRange.d.ts +0 -1
- package/module/es5/IP/isInRange.js +5 -29
- package/module/es5/IP/isPrivateIp.d.ts +0 -1
- package/module/es5/IP/isPrivateIp.js +3 -12
- package/module/es5/IP/longToIp.d.ts +0 -1
- package/module/es5/IP/longToIp.js +0 -6
- package/module/es5/IP/subnetMaskToCidr.d.ts +0 -1
- package/module/es5/IP/subnetMaskToCidr.js +2 -26
- package/module/es5/Iterator/index.d.ts +3 -0
- package/module/es5/Iterator/index.js +38 -0
- package/module/es5/Iterator/lazyFilter.d.ts +10 -0
- package/module/es5/Iterator/lazyFilter.js +63 -0
- package/module/es5/Iterator/lazyMap.d.ts +10 -0
- package/module/es5/Iterator/lazyMap.js +59 -0
- package/module/es5/Iterator/lazyTake.d.ts +10 -0
- package/module/es5/Iterator/lazyTake.js +65 -0
- package/module/es5/Math/addition.js +24 -14
- package/module/es5/Math/average.js +3 -5
- package/module/es5/Math/bitwise.js +1 -1
- package/module/es5/Math/calculator/core.js +2 -1
- package/module/es5/Math/calculator/literalExpression.js +1 -1
- package/module/es5/Math/clamp.d.ts +16 -0
- package/module/es5/Math/clamp.js +24 -0
- package/module/es5/Math/correlationCoefficient.js +0 -3
- package/module/es5/Math/inRange.d.ts +19 -0
- package/module/es5/Math/inRange.js +29 -0
- package/module/es5/Math/index.d.ts +3 -0
- package/module/es5/Math/index.js +33 -0
- package/module/es5/Math/median.js +2 -2
- package/module/es5/Math/nCr.js +2 -4
- package/module/es5/Math/percentile.js +2 -11
- package/module/es5/Math/primeFactorization.js +1 -1
- package/module/es5/Math/sumPrecise.d.ts +14 -0
- package/module/es5/Math/sumPrecise.js +41 -0
- package/module/es5/Math/uuidv7.js +25 -40
- package/module/es5/Number/formatNumber.d.ts +42 -0
- package/module/es5/Number/formatNumber.js +58 -0
- package/module/es5/Number/index.d.ts +3 -0
- package/module/es5/Number/index.js +38 -0
- package/module/es5/Number/toOrdinal.d.ts +20 -0
- package/module/es5/Number/toOrdinal.js +42 -0
- package/module/es5/Number/toPercentage.d.ts +20 -0
- package/module/es5/Number/toPercentage.js +33 -0
- package/module/es5/Object/deepClone.d.ts +15 -0
- package/module/es5/Object/deepClone.js +107 -0
- package/module/es5/Object/getObjectsCommon.d.ts +23 -0
- package/module/es5/Object/getObjectsCommon.js +92 -0
- package/module/es5/Object/getObjectsDiff.d.ts +25 -0
- package/module/es5/Object/getObjectsDiff.js +146 -0
- package/module/es5/Object/index.d.ts +6 -0
- package/module/es5/Object/index.js +66 -0
- package/module/es5/Object/isPlainObject.d.ts +16 -0
- package/module/es5/Object/isPlainObject.js +39 -0
- package/module/es5/Object/mapKeys.d.ts +15 -0
- package/module/es5/Object/mapKeys.js +33 -0
- package/module/es5/Object/mapValues.d.ts +15 -0
- package/module/es5/Object/mapValues.js +32 -0
- package/module/es5/Object/mergeDeep.js +7 -10
- package/module/es5/Object/omit.d.ts +1 -1
- package/module/es5/Object/pickDeep.js +4 -6
- package/module/es5/Predicate/every.d.ts +14 -0
- package/module/es5/Predicate/every.js +33 -0
- package/module/es5/Predicate/index.d.ts +6 -0
- package/module/es5/Predicate/index.js +71 -0
- package/module/es5/Predicate/isNotNullish.d.ts +11 -0
- package/module/es5/Predicate/isNotNullish.js +19 -0
- package/module/es5/Predicate/isNullish.d.ts +11 -0
- package/module/es5/Predicate/isNullish.js +19 -0
- package/module/es5/Predicate/matches.d.ts +11 -0
- package/module/es5/Predicate/matches.js +28 -0
- package/module/es5/Predicate/not.d.ts +10 -0
- package/module/es5/Predicate/not.js +20 -0
- package/module/es5/Predicate/some.d.ts +15 -0
- package/module/es5/Predicate/some.js +34 -0
- package/module/es5/String/camelCase.js +2 -2
- package/module/es5/String/escapeHtml.js +1 -1
- package/module/es5/String/formatString/getValue.js +1 -1
- package/module/es5/String/fromBase64.d.ts +0 -1
- package/module/es5/String/fromBase64.js +9 -8
- package/module/es5/String/fuzzySearch.js +84 -9
- package/module/es5/String/kebabCase.js +1 -1
- package/module/es5/String/levenshteinDistance.js +3 -2
- package/module/es5/String/randomString.js +24 -2
- package/module/es5/String/reverseString.js +7 -1
- package/module/es5/String/slugify.js +1 -1
- package/module/es5/String/toHalfWidth.js +2 -2
- package/module/es5/String/truncate.js +0 -3
- package/module/es5/String/unescapeHtml.js +1 -1
- package/module/es5/Time/convertTime.js +4 -3
- package/module/es5/Tool/escapeRegExp.d.ts +8 -0
- package/module/es5/Tool/escapeRegExp.js +18 -0
- package/module/es5/Tool/index.d.ts +1 -0
- package/module/es5/Tool/index.js +11 -0
- package/module/es5/URL/buildUrl.d.ts +17 -0
- package/module/es5/URL/buildUrl.js +31 -0
- package/module/es5/URL/index.d.ts +4 -0
- package/module/es5/URL/index.js +49 -0
- package/module/es5/URL/isAbsoluteUrl.d.ts +20 -0
- package/module/es5/URL/isAbsoluteUrl.js +28 -0
- package/module/es5/URL/joinPath.d.ts +24 -0
- package/module/es5/URL/joinPath.js +48 -0
- package/module/es5/URL/parseQueryString.d.ts +22 -0
- package/module/es5/URL/parseQueryString.js +57 -0
- package/module/es5/Validate/parseEmail.js +5 -5
- package/module/es5/index.d.ts +25 -20
- package/module/es5/index.js +135 -80
- package/module/es5/tsconfig.tsbuildinfo +1 -1
- package/module/index.d.ts +25 -20
- package/module/index.js +25 -20
- package/module/index.js.map +1 -1
- package/package.json +43 -17
package/module/Math/median.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { ultraNumberSort } from "../Array/ultraNumberSort";
|
|
2
2
|
/**
|
|
3
3
|
* Calculate the median of an array of numbers
|
|
4
4
|
* @param {number[]} array Array of numbers
|
|
@@ -6,7 +6,7 @@ import { quickSort } from "../Array/quickSort";
|
|
|
6
6
|
* @example median([1, 3, 3, 6, 7, 8, 9]); // 6
|
|
7
7
|
*/
|
|
8
8
|
export const median = (array) => {
|
|
9
|
-
const sortedArray =
|
|
9
|
+
const sortedArray = ultraNumberSort(array);
|
|
10
10
|
const mid = Math.floor(sortedArray.length / 2);
|
|
11
11
|
return sortedArray.length % 2 === 0
|
|
12
12
|
? (sortedArray[mid - 1] + sortedArray[mid]) / 2
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"median.js","sourceRoot":"","sources":["../../src/Math/median.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,
|
|
1
|
+
{"version":3,"file":"median.js","sourceRoot":"","sources":["../../src/Math/median.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,eAAe,EAAE,MAAM,yBAAyB,CAAC;AAE1D;;;;;GAKG;AACH,MAAM,CAAC,MAAM,MAAM,GAAG,CAAC,KAAe,EAAU,EAAE;IAChD,MAAM,WAAW,GAAa,eAAe,CAAC,KAAK,CAAC,CAAC;IACrD,MAAM,GAAG,GAAG,IAAI,CAAC,KAAK,CAAC,WAAW,CAAC,MAAM,GAAG,CAAC,CAAC,CAAC;IAE/C,OAAO,WAAW,CAAC,MAAM,GAAG,CAAC,KAAK,CAAC;QACjC,CAAC,CAAC,CAAC,WAAW,CAAC,GAAG,GAAG,CAAC,CAAC,GAAG,WAAW,CAAC,GAAG,CAAC,CAAC,GAAG,CAAC;QAC/C,CAAC,CAAC,WAAW,CAAC,GAAG,CAAC,CAAC;AACvB,CAAC,CAAC"}
|
package/module/Math/nCr.js
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { factorial } from "./factorial";
|
|
1
2
|
import { nPr } from "./nPr";
|
|
2
3
|
/**
|
|
3
4
|
* Calculates combinations (nCr) - number of ways to choose r items from n items
|
|
@@ -17,10 +18,7 @@ export const nCr = (n, r) => {
|
|
|
17
18
|
return 1;
|
|
18
19
|
}
|
|
19
20
|
const numerator = nPr(n, r);
|
|
20
|
-
|
|
21
|
-
for (let index = 2; index <= r; index++) {
|
|
22
|
-
denominator *= index;
|
|
23
|
-
}
|
|
21
|
+
const denominator = factorial(r);
|
|
24
22
|
const result = numerator / denominator;
|
|
25
23
|
return result;
|
|
26
24
|
};
|
package/module/Math/nCr.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"nCr.js","sourceRoot":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4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { ultraNumberSort } from "../Array/ultraNumberSort";
|
|
2
2
|
/**
|
|
3
3
|
* Calculate the nth percentile of values in an array
|
|
4
4
|
* @param array - Array of numbers
|
|
@@ -13,10 +13,7 @@ export const percentile = (array, percentile) => {
|
|
|
13
13
|
if (array.length === 0) {
|
|
14
14
|
return Number.NaN;
|
|
15
15
|
}
|
|
16
|
-
|
|
17
|
-
throw new Error("Percentile must be between 0 and 100");
|
|
18
|
-
}
|
|
19
|
-
const sortedArray = quickSort([...array]);
|
|
16
|
+
const sortedArray = ultraNumberSort(array);
|
|
20
17
|
const index = (percentile / 100) * (sortedArray.length - 1);
|
|
21
18
|
const lowerIndex = Math.floor(index);
|
|
22
19
|
const upperIndex = Math.ceil(index);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"percentile.js","sourceRoot":"","sources":["../../src/Math/percentile.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,
|
|
1
|
+
{"version":3,"file":"percentile.js","sourceRoot":"","sources":["../../src/Math/percentile.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,eAAe,EAAE,MAAM,yBAAyB,CAAC;AAE1D;;;;;;;;;GASG;AACH,MAAM,CAAC,MAAM,UAAU,GAAG,CAAC,KAAe,EAAE,UAAkB,EAAU,EAAE;IACxE,IAAI,KAAK,CAAC,MAAM,KAAK,CAAC,EAAE,CAAC;QACvB,OAAO,MAAM,CAAC,GAAG,CAAC;IACpB,CAAC;IAED,MAAM,WAAW,GAAG,eAAe,CAAC,KAAK,CAAC,CAAC;IAC3C,MAAM,KAAK,GAAG,CAAC,UAAU,GAAG,GAAG,CAAC,GAAG,CAAC,WAAW,CAAC,MAAM,GAAG,CAAC,CAAC,CAAC;IAC5D,MAAM,UAAU,GAAG,IAAI,CAAC,KAAK,CAAC,KAAK,CAAC,CAAC;IACrC,MAAM,UAAU,GAAG,IAAI,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC;IAEpC,IAAI,UAAU,KAAK,UAAU,EAAE,CAAC;QAC9B,OAAO,WAAW,CAAC,UAAU,CAAC,CAAC;IACjC,CAAC;IAED,MAAM,UAAU,GAAG,WAAW,CAAC,UAAU,CAAC,CAAC;IAC3C,MAAM,UAAU,GAAG,WAAW,CAAC,UAAU,CAAC,CAAC;IAC3C,MAAM,MAAM,GAAG,KAAK,GAAG,UAAU,CAAC;IAElC,OAAO,UAAU,GAAG,CAAC,UAAU,GAAG,UAAU,CAAC,GAAG,MAAM,CAAC;AACzD,CAAC,CAAC"}
|
|
@@ -8,7 +8,7 @@
|
|
|
8
8
|
* For example, 12 = 2^2 * 3^1 is represented as [{number: 2, count: 2}, {number: 3, count: 1}]
|
|
9
9
|
*/
|
|
10
10
|
export const primeFactorization = (x) => {
|
|
11
|
-
let n
|
|
11
|
+
let n;
|
|
12
12
|
let copyX = x;
|
|
13
13
|
const out = [];
|
|
14
14
|
for (let index = 2; index * index <= copyX; index++) {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"primeFactorization.js","sourceRoot":"","sources":["../../src/Math/primeFactorization.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AACH,MAAM,CAAC,MAAM,kBAAkB,GAAG,CAAC,CAAS,EAAE,EAAE;IAC9C,IAAI,
|
|
1
|
+
{"version":3,"file":"primeFactorization.js","sourceRoot":"","sources":["../../src/Math/primeFactorization.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AACH,MAAM,CAAC,MAAM,kBAAkB,GAAG,CAAC,CAAS,EAAE,EAAE;IAC9C,IAAI,CAAS,CAAC;IACd,IAAI,KAAK,GAAG,CAAC,CAAC;IACd,MAAM,GAAG,GAAwC,EAAE,CAAC;IACpD,KAAK,IAAI,KAAK,GAAG,CAAC,EAAE,KAAK,GAAG,KAAK,IAAI,KAAK,EAAE,KAAK,EAAE,EAAE,CAAC;QACpD,IAAI,KAAK,GAAG,KAAK,KAAK,CAAC,EAAE,CAAC;YACxB,CAAC,GAAG,CAAC,CAAC;YACN,OAAO,KAAK,GAAG,KAAK,KAAK,CAAC,EAAE,CAAC;gBAC3B,CAAC,EAAE,CAAC;gBACJ,KAAK,IAAI,KAAK,CAAC;YACjB,CAAC;YACD,GAAG,CAAC,IAAI,CAAC,EAAE,MAAM,EAAE,KAAK,EAAE,KAAK,EAAE,CAAC,EAAE,CAAC,CAAC;QACxC,CAAC;IACH,CAAC;IACD,4DAA4D;IAC5D,IAAI,KAAK,GAAG,CAAC,EAAE,CAAC;QACd,GAAG,CAAC,IAAI,CAAC,EAAE,MAAM,EAAE,KAAK,EAAE,KAAK,EAAE,CAAC,EAAE,CAAC,CAAC;IACxC,CAAC;IACD,OAAO,GAAG,CAAC;AACb,CAAC,CAAC"}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Computes the sum of an array of numbers using the Neumaier
|
|
3
|
+
* summation algorithm for improved floating-point precision.
|
|
4
|
+
*
|
|
5
|
+
* @param numbers - The array of numbers to sum.
|
|
6
|
+
* @returns The precise sum of all numbers.
|
|
7
|
+
*
|
|
8
|
+
* @example
|
|
9
|
+
* ```typescript
|
|
10
|
+
* sumPrecise([0.1, 0.2, 0.3]); // 0.6
|
|
11
|
+
* sumPrecise([1e20, 1, -1e20]); // 1
|
|
12
|
+
* ```
|
|
13
|
+
*/
|
|
14
|
+
export declare const sumPrecise: (numbers: number[]) => number;
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Computes the sum of an array of numbers using the Neumaier
|
|
3
|
+
* summation algorithm for improved floating-point precision.
|
|
4
|
+
*
|
|
5
|
+
* @param numbers - The array of numbers to sum.
|
|
6
|
+
* @returns The precise sum of all numbers.
|
|
7
|
+
*
|
|
8
|
+
* @example
|
|
9
|
+
* ```typescript
|
|
10
|
+
* sumPrecise([0.1, 0.2, 0.3]); // 0.6
|
|
11
|
+
* sumPrecise([1e20, 1, -1e20]); // 1
|
|
12
|
+
* ```
|
|
13
|
+
*/
|
|
14
|
+
export const sumPrecise = (numbers) => {
|
|
15
|
+
let sum = 0;
|
|
16
|
+
let compensation = 0;
|
|
17
|
+
for (const number_ of numbers) {
|
|
18
|
+
const t = sum + number_;
|
|
19
|
+
compensation +=
|
|
20
|
+
Math.abs(sum) >= Math.abs(number_)
|
|
21
|
+
? sum - t + number_
|
|
22
|
+
: number_ - t + sum;
|
|
23
|
+
sum = t;
|
|
24
|
+
}
|
|
25
|
+
return sum + compensation;
|
|
26
|
+
};
|
|
27
|
+
//# sourceMappingURL=sumPrecise.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"sumPrecise.js","sourceRoot":"","sources":["../../src/Math/sumPrecise.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;GAYG;AACH,MAAM,CAAC,MAAM,UAAU,GAAG,CAAC,OAAiB,EAAU,EAAE;IACtD,IAAI,GAAG,GAAG,CAAC,CAAC;IACZ,IAAI,YAAY,GAAG,CAAC,CAAC;IAErB,KAAK,MAAM,OAAO,IAAI,OAAO,EAAE,CAAC;QAC9B,MAAM,CAAC,GAAG,GAAG,GAAG,OAAO,CAAC;QACxB,YAAY;YACV,IAAI,CAAC,GAAG,CAAC,GAAG,CAAC,IAAI,IAAI,CAAC,GAAG,CAAC,OAAO,CAAC;gBAChC,CAAC,CAAC,GAAG,GAAG,CAAC,GAAG,OAAO;gBACnB,CAAC,CAAC,OAAO,GAAG,CAAC,GAAG,GAAG,CAAC;QACxB,GAAG,GAAG,CAAC,CAAC;IACV,CAAC;IAED,OAAO,GAAG,GAAG,YAAY,CAAC;AAC5B,CAAC,CAAC"}
|
package/module/Math/uuidv7.js
CHANGED
|
@@ -14,28 +14,62 @@
|
|
|
14
14
|
export const uuidv7 = () => {
|
|
15
15
|
const DIGITS = "0123456789abcdef";
|
|
16
16
|
const unixTsMs = Date.now();
|
|
17
|
+
// Create a single 16-byte buffer for the UUID
|
|
17
18
|
const bytes = new Uint8Array(16);
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
//
|
|
25
|
-
bytes[
|
|
26
|
-
|
|
27
|
-
bytes[
|
|
28
|
-
|
|
29
|
-
bytes[
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
19
|
+
// Fill the entire buffer with random data first.
|
|
20
|
+
// This avoids allocating a separate 10-byte buffer for randomness.
|
|
21
|
+
// We will overwrite the first 6 bytes with the timestamp.
|
|
22
|
+
globalThis.crypto.getRandomValues(bytes);
|
|
23
|
+
// Overwrite first 6 bytes with 48-bit timestamp (Big-Endian)
|
|
24
|
+
// Note: We use division for the high 16 bits because JS bitwise operators (>>>)
|
|
25
|
+
// truncate to 32 bits, which would corrupt the 48-bit timestamp.
|
|
26
|
+
bytes[0] = (unixTsMs / 0x1_00_00_00_00_00) & 0xff;
|
|
27
|
+
bytes[1] = (unixTsMs / 0x1_00_00_00_00) & 0xff;
|
|
28
|
+
bytes[2] = (unixTsMs >>> 24) & 0xff;
|
|
29
|
+
bytes[3] = (unixTsMs >>> 16) & 0xff;
|
|
30
|
+
bytes[4] = (unixTsMs >>> 8) & 0xff;
|
|
31
|
+
bytes[5] = unixTsMs & 0xff;
|
|
32
|
+
// Version 7 (0x70) + 4 bits from random data (already in bytes[6])
|
|
33
|
+
bytes[6] = 0x70 | (bytes[6] & 0x0f);
|
|
34
|
+
// Variant 2 (0x80) + 6 bits from random data (already in bytes[8])
|
|
35
|
+
bytes[8] = 0x80 | (bytes[8] & 0x3f);
|
|
36
|
+
// Convert to string (unrolled for performance)
|
|
37
|
+
// Format: 8-4-4-4-12 hex digits (xxxxxxxx-xxxx-7xxx-8xxx-xxxxxxxxxxxx)
|
|
38
|
+
return (DIGITS[bytes[0] >>> 4] +
|
|
39
|
+
DIGITS[bytes[0] & 0xf] +
|
|
40
|
+
DIGITS[bytes[1] >>> 4] +
|
|
41
|
+
DIGITS[bytes[1] & 0xf] +
|
|
42
|
+
DIGITS[bytes[2] >>> 4] +
|
|
43
|
+
DIGITS[bytes[2] & 0xf] +
|
|
44
|
+
DIGITS[bytes[3] >>> 4] +
|
|
45
|
+
DIGITS[bytes[3] & 0xf] +
|
|
46
|
+
"-" +
|
|
47
|
+
DIGITS[bytes[4] >>> 4] +
|
|
48
|
+
DIGITS[bytes[4] & 0xf] +
|
|
49
|
+
DIGITS[bytes[5] >>> 4] +
|
|
50
|
+
DIGITS[bytes[5] & 0xf] +
|
|
51
|
+
"-" +
|
|
52
|
+
DIGITS[bytes[6] >>> 4] +
|
|
53
|
+
DIGITS[bytes[6] & 0xf] +
|
|
54
|
+
DIGITS[bytes[7] >>> 4] +
|
|
55
|
+
DIGITS[bytes[7] & 0xf] +
|
|
56
|
+
"-" +
|
|
57
|
+
DIGITS[bytes[8] >>> 4] +
|
|
58
|
+
DIGITS[bytes[8] & 0xf] +
|
|
59
|
+
DIGITS[bytes[9] >>> 4] +
|
|
60
|
+
DIGITS[bytes[9] & 0xf] +
|
|
61
|
+
"-" +
|
|
62
|
+
DIGITS[bytes[10] >>> 4] +
|
|
63
|
+
DIGITS[bytes[10] & 0xf] +
|
|
64
|
+
DIGITS[bytes[11] >>> 4] +
|
|
65
|
+
DIGITS[bytes[11] & 0xf] +
|
|
66
|
+
DIGITS[bytes[12] >>> 4] +
|
|
67
|
+
DIGITS[bytes[12] & 0xf] +
|
|
68
|
+
DIGITS[bytes[13] >>> 4] +
|
|
69
|
+
DIGITS[bytes[13] & 0xf] +
|
|
70
|
+
DIGITS[bytes[14] >>> 4] +
|
|
71
|
+
DIGITS[bytes[14] & 0xf] +
|
|
72
|
+
DIGITS[bytes[15] >>> 4] +
|
|
73
|
+
DIGITS[bytes[15] & 0xf]);
|
|
40
74
|
};
|
|
41
75
|
//# sourceMappingURL=uuidv7.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"uuidv7.js","sourceRoot":"","sources":["../../src/Math/uuidv7.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;GAYG;AACH,MAAM,CAAC,MAAM,MAAM,GAAG,GAAW,EAAE;IACjC,MAAM,MAAM,GAAG,kBAAkB,CAAC;IAClC,MAAM,QAAQ,GAAG,IAAI,CAAC,GAAG,EAAE,CAAC;IAE5B,MAAM,KAAK,GAAG,IAAI,UAAU,CAAC,EAAE,CAAC,CAAC;
|
|
1
|
+
{"version":3,"file":"uuidv7.js","sourceRoot":"","sources":["../../src/Math/uuidv7.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;GAYG;AACH,MAAM,CAAC,MAAM,MAAM,GAAG,GAAW,EAAE;IACjC,MAAM,MAAM,GAAG,kBAAkB,CAAC;IAClC,MAAM,QAAQ,GAAG,IAAI,CAAC,GAAG,EAAE,CAAC;IAE5B,8CAA8C;IAC9C,MAAM,KAAK,GAAG,IAAI,UAAU,CAAC,EAAE,CAAC,CAAC;IAEjC,iDAAiD;IACjD,mEAAmE;IACnE,0DAA0D;IAC1D,UAAU,CAAC,MAAM,CAAC,eAAe,CAAC,KAAK,CAAC,CAAC;IAEzC,6DAA6D;IAC7D,gFAAgF;IAChF,iEAAiE;IACjE,KAAK,CAAC,CAAC,CAAC,GAAG,CAAC,QAAQ,GAAG,kBAAkB,CAAC,GAAG,IAAI,CAAC;IAClD,KAAK,CAAC,CAAC,CAAC,GAAG,CAAC,QAAQ,GAAG,eAAe,CAAC,GAAG,IAAI,CAAC;IAC/C,KAAK,CAAC,CAAC,CAAC,GAAG,CAAC,QAAQ,KAAK,EAAE,CAAC,GAAG,IAAI,CAAC;IACpC,KAAK,CAAC,CAAC,CAAC,GAAG,CAAC,QAAQ,KAAK,EAAE,CAAC,GAAG,IAAI,CAAC;IACpC,KAAK,CAAC,CAAC,CAAC,GAAG,CAAC,QAAQ,KAAK,CAAC,CAAC,GAAG,IAAI,CAAC;IACnC,KAAK,CAAC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g., "en-US", "ja-JP") */
|
|
6
|
+
locale?: string;
|
|
7
|
+
/** Minimum number of fraction digits */
|
|
8
|
+
minimumFractionDigits?: number;
|
|
9
|
+
/** Maximum number of fraction digits */
|
|
10
|
+
maximumFractionDigits?: number;
|
|
11
|
+
/** The formatting style */
|
|
12
|
+
style?: "decimal" | "currency" | "percent";
|
|
13
|
+
/** The currency code (required when style is "currency") */
|
|
14
|
+
currency?: string;
|
|
15
|
+
}
|
|
16
|
+
/**
|
|
17
|
+
* Formats a number using Intl.NumberFormat.
|
|
18
|
+
*
|
|
19
|
+
* @param value - The number to format
|
|
20
|
+
* @param options - Formatting options
|
|
21
|
+
* @returns The formatted number string
|
|
22
|
+
*
|
|
23
|
+
* @example
|
|
24
|
+
* ```typescript
|
|
25
|
+
* formatNumber(1234567.89);
|
|
26
|
+
* // "1,234,567.89" (in en-US locale)
|
|
27
|
+
*
|
|
28
|
+
* formatNumber(1234567.89, { locale: "de-DE" });
|
|
29
|
+
* // "1.234.567,89"
|
|
30
|
+
*
|
|
31
|
+
* formatNumber(0.75, { style: "percent" });
|
|
32
|
+
* // "75%"
|
|
33
|
+
*
|
|
34
|
+
* formatNumber(1234.5, {
|
|
35
|
+
* style: "currency",
|
|
36
|
+
* currency: "USD",
|
|
37
|
+
* locale: "en-US",
|
|
38
|
+
* });
|
|
39
|
+
* // "$1,234.50"
|
|
40
|
+
* ```
|
|
41
|
+
*/
|
|
42
|
+
export declare const formatNumber: (value: number, options?: FormatNumberOptions) => string;
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Formats a number using Intl.NumberFormat.
|
|
3
|
+
*
|
|
4
|
+
* @param value - The number to format
|
|
5
|
+
* @param options - Formatting options
|
|
6
|
+
* @returns The formatted number string
|
|
7
|
+
*
|
|
8
|
+
* @example
|
|
9
|
+
* ```typescript
|
|
10
|
+
* formatNumber(1234567.89);
|
|
11
|
+
* // "1,234,567.89" (in en-US locale)
|
|
12
|
+
*
|
|
13
|
+
* formatNumber(1234567.89, { locale: "de-DE" });
|
|
14
|
+
* // "1.234.567,89"
|
|
15
|
+
*
|
|
16
|
+
* formatNumber(0.75, { style: "percent" });
|
|
17
|
+
* // "75%"
|
|
18
|
+
*
|
|
19
|
+
* formatNumber(1234.5, {
|
|
20
|
+
* style: "currency",
|
|
21
|
+
* currency: "USD",
|
|
22
|
+
* locale: "en-US",
|
|
23
|
+
* });
|
|
24
|
+
* // "$1,234.50"
|
|
25
|
+
* ```
|
|
26
|
+
*/
|
|
27
|
+
export const formatNumber = (value, options = {}) => {
|
|
28
|
+
const { locale, minimumFractionDigits, maximumFractionDigits, style, currency, } = options;
|
|
29
|
+
const formatOptions = {};
|
|
30
|
+
if (style !== undefined) {
|
|
31
|
+
formatOptions.style = style;
|
|
32
|
+
}
|
|
33
|
+
if (currency !== undefined) {
|
|
34
|
+
formatOptions.currency = currency;
|
|
35
|
+
}
|
|
36
|
+
if (minimumFractionDigits !== undefined) {
|
|
37
|
+
formatOptions.minimumFractionDigits = minimumFractionDigits;
|
|
38
|
+
}
|
|
39
|
+
if (maximumFractionDigits !== undefined) {
|
|
40
|
+
formatOptions.maximumFractionDigits = maximumFractionDigits;
|
|
41
|
+
}
|
|
42
|
+
return new Intl.NumberFormat(locale, formatOptions).format(value);
|
|
43
|
+
};
|
|
44
|
+
//# sourceMappingURL=formatNumber.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"formatNumber.js","sourceRoot":"","sources":["../../src/Number/formatNumber.ts"],"names":[],"mappings":"AAgBA;;;;;;;;;;;;;;;;;;;;;;;;;GAyBG;AACH,MAAM,CAAC,MAAM,YAAY,GAAG,CAC1B,KAAa,EACb,UAA+B,EAAE,EACzB,EAAE;IACV,MAAM,EACJ,MAAM,EACN,qBAAqB,EACrB,qBAAqB,EACrB,KAAK,EACL,QAAQ,GACT,GAAG,OAAO,CAAC;IAEZ,MAAM,aAAa,GAA6B,EAAE,CAAC;IAEnD,IAAI,KAAK,KAAK,SAAS,EAAE,CAAC;QACxB,aAAa,CAAC,KAAK,GAAG,KAAK,CAAC;IAC9B,CAAC;IACD,IAAI,QAAQ,KAAK,SAAS,EAAE,CAAC;QAC3B,aAAa,CAAC,QAAQ,GAAG,QAAQ,CAAC;IACpC,CAAC;IACD,IAAI,qBAAqB,KAAK,SAAS,EAAE,CAAC;QACxC,aAAa,CAAC,qBAAqB,GAAG,qBAAqB,CAAC;IAC9D,CAAC;IACD,IAAI,qBAAqB,KAAK,SAAS,EAAE,CAAC;QACxC,aAAa,CAAC,qBAAqB,GAAG,qBAAqB,CAAC;IAC9D,CAAC;IAED,OAAO,IAAI,IAAI,CAAC,YAAY,CAAC,MAAM,EAAE,aAAa,CAAC,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC;AACpE,CAAC,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/Number/index.ts"],"names":[],"mappings":"AAAA,cAAc,gBAAgB,CAAC;AAC/B,cAAc,aAAa,CAAC;AAC5B,cAAc,gBAAgB,CAAC"}
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Converts a number to its English ordinal string representation.
|
|
3
|
+
*
|
|
4
|
+
* Handles the special cases for 11th, 12th, and 13th
|
|
5
|
+
* (which end in "th" despite their last digit).
|
|
6
|
+
*
|
|
7
|
+
* @param value - The number to convert to ordinal form
|
|
8
|
+
* @returns The ordinal string (e.g., "1st", "2nd", "3rd", "11th")
|
|
9
|
+
*
|
|
10
|
+
* @example
|
|
11
|
+
* ```typescript
|
|
12
|
+
* toOrdinal(1); // "1st"
|
|
13
|
+
* toOrdinal(2); // "2nd"
|
|
14
|
+
* toOrdinal(3); // "3rd"
|
|
15
|
+
* toOrdinal(11); // "11th"
|
|
16
|
+
* toOrdinal(21); // "21st"
|
|
17
|
+
* toOrdinal(112); // "112th"
|
|
18
|
+
* ```
|
|
19
|
+
*/
|
|
20
|
+
export declare const toOrdinal: (value: number) => string;
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Converts a number to its English ordinal string representation.
|
|
3
|
+
*
|
|
4
|
+
* Handles the special cases for 11th, 12th, and 13th
|
|
5
|
+
* (which end in "th" despite their last digit).
|
|
6
|
+
*
|
|
7
|
+
* @param value - The number to convert to ordinal form
|
|
8
|
+
* @returns The ordinal string (e.g., "1st", "2nd", "3rd", "11th")
|
|
9
|
+
*
|
|
10
|
+
* @example
|
|
11
|
+
* ```typescript
|
|
12
|
+
* toOrdinal(1); // "1st"
|
|
13
|
+
* toOrdinal(2); // "2nd"
|
|
14
|
+
* toOrdinal(3); // "3rd"
|
|
15
|
+
* toOrdinal(11); // "11th"
|
|
16
|
+
* toOrdinal(21); // "21st"
|
|
17
|
+
* toOrdinal(112); // "112th"
|
|
18
|
+
* ```
|
|
19
|
+
*/
|
|
20
|
+
export const toOrdinal = (value) => {
|
|
21
|
+
const module100 = value % 100;
|
|
22
|
+
if (module100 >= 11 && module100 <= 13) {
|
|
23
|
+
return `${value}th`;
|
|
24
|
+
}
|
|
25
|
+
const module10 = value % 10;
|
|
26
|
+
if (module10 === 1) {
|
|
27
|
+
return `${value}st`;
|
|
28
|
+
}
|
|
29
|
+
if (module10 === 2) {
|
|
30
|
+
return `${value}nd`;
|
|
31
|
+
}
|
|
32
|
+
if (module10 === 3) {
|
|
33
|
+
return `${value}rd`;
|
|
34
|
+
}
|
|
35
|
+
return `${value}th`;
|
|
36
|
+
};
|
|
37
|
+
//# sourceMappingURL=toOrdinal.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"toOrdinal.js","sourceRoot":"","sources":["../../src/Number/toOrdinal.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;GAkBG;AACH,MAAM,CAAC,MAAM,SAAS,GAAG,CAAC,KAAa,EAAU,EAAE;IACjD,MAAM,SAAS,GAAG,KAAK,GAAG,GAAG,CAAC;IAC9B,IAAI,SAAS,IAAI,EAAE,IAAI,SAAS,IAAI,EAAE,EAAE,CAAC;QACvC,OAAO,GAAG,KAAK,IAAI,CAAC;IACtB,CAAC;IAED,MAAM,QAAQ,GAAG,KAAK,GAAG,EAAE,CAAC;IAC5B,IAAI,QAAQ,KAAK,CAAC,EAAE,CAAC;QACnB,OAAO,GAAG,KAAK,IAAI,CAAC;IACtB,CAAC;IACD,IAAI,QAAQ,KAAK,CAAC,EAAE,CAAC;QACnB,OAAO,GAAG,KAAK,IAAI,CAAC;IACtB,CAAC;IACD,IAAI,QAAQ,KAAK,CAAC,EAAE,CAAC;QACnB,OAAO,GAAG,KAAK,IAAI,CAAC;IACtB,CAAC;IAED,OAAO,GAAG,KAAK,IAAI,CAAC;AACtB,CAAC,CAAC"}
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Calculates the percentage of a value relative to a total.
|
|
3
|
+
*
|
|
4
|
+
* Returns 0 when the total is 0 to avoid division by zero.
|
|
5
|
+
*
|
|
6
|
+
* @param value - The partial value
|
|
7
|
+
* @param total - The total value
|
|
8
|
+
* @param decimals - The number of decimal places (default 2)
|
|
9
|
+
* @returns The percentage value
|
|
10
|
+
*
|
|
11
|
+
* @example
|
|
12
|
+
* ```typescript
|
|
13
|
+
* toPercentage(25, 100); // 25
|
|
14
|
+
* toPercentage(1, 3); // 33.33
|
|
15
|
+
* toPercentage(1, 3, 0); // 33
|
|
16
|
+
* toPercentage(0, 0); // 0
|
|
17
|
+
* toPercentage(50, 200, 1); // 25.0 -> 25
|
|
18
|
+
* ```
|
|
19
|
+
*/
|
|
20
|
+
export declare const toPercentage: (value: number, total: number, decimals?: number) => number;
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Calculates the percentage of a value relative to a total.
|
|
3
|
+
*
|
|
4
|
+
* Returns 0 when the total is 0 to avoid division by zero.
|
|
5
|
+
*
|
|
6
|
+
* @param value - The partial value
|
|
7
|
+
* @param total - The total value
|
|
8
|
+
* @param decimals - The number of decimal places (default 2)
|
|
9
|
+
* @returns The percentage value
|
|
10
|
+
*
|
|
11
|
+
* @example
|
|
12
|
+
* ```typescript
|
|
13
|
+
* toPercentage(25, 100); // 25
|
|
14
|
+
* toPercentage(1, 3); // 33.33
|
|
15
|
+
* toPercentage(1, 3, 0); // 33
|
|
16
|
+
* toPercentage(0, 0); // 0
|
|
17
|
+
* toPercentage(50, 200, 1); // 25.0 -> 25
|
|
18
|
+
* ```
|
|
19
|
+
*/
|
|
20
|
+
export const toPercentage = (value, total, decimals = 2) => {
|
|
21
|
+
if (total === 0) {
|
|
22
|
+
return 0;
|
|
23
|
+
}
|
|
24
|
+
const factor = 10 ** decimals;
|
|
25
|
+
return Math.round((value / total) * 100 * factor) / factor;
|
|
26
|
+
};
|
|
27
|
+
//# sourceMappingURL=toPercentage.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"toPercentage.js","sourceRoot":"","sources":["../../src/Number/toPercentage.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;GAkBG;AACH,MAAM,CAAC,MAAM,YAAY,GAAG,CAC1B,KAAa,EACb,KAAa,EACb,QAAQ,GAAG,CAAC,EACJ,EAAE;IACV,IAAI,KAAK,KAAK,CAAC,EAAE,CAAC;QAChB,OAAO,CAAC,CAAC;IACX,CAAC;IAED,MAAM,MAAM,GAAG,EAAE,IAAI,QAAQ,CAAC;IAC9B,OAAO,IAAI,CAAC,KAAK,CAAC,CAAC,KAAK,GAAG,KAAK,CAAC,GAAG,GAAG,GAAG,MAAM,CAAC,GAAG,MAAM,CAAC;AAC7D,CAAC,CAAC"}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Creates a deep clone of the given value.
|
|
3
|
+
*
|
|
4
|
+
* @param value - The value to deep clone.
|
|
5
|
+
* @returns A deep clone of the input value.
|
|
6
|
+
*
|
|
7
|
+
* @example
|
|
8
|
+
* ```typescript
|
|
9
|
+
* const original = { a: 1, b: { c: 2 } };
|
|
10
|
+
* const cloned = deepClone(original);
|
|
11
|
+
* cloned.b.c = 99;
|
|
12
|
+
* original.b.c; // still 2
|
|
13
|
+
* ```
|
|
14
|
+
*/
|
|
15
|
+
export declare const deepClone: <T>(value: T) => T;
|
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Recursively clones a value.
|
|
3
|
+
*/
|
|
4
|
+
const cloneValue = (value) => {
|
|
5
|
+
if (value === null || typeof value !== "object") {
|
|
6
|
+
return value;
|
|
7
|
+
}
|
|
8
|
+
if (Array.isArray(value)) {
|
|
9
|
+
const result = [];
|
|
10
|
+
for (const element of value) {
|
|
11
|
+
result.push(cloneValue(element));
|
|
12
|
+
}
|
|
13
|
+
return result;
|
|
14
|
+
}
|
|
15
|
+
if (value instanceof Date) {
|
|
16
|
+
return new Date(value);
|
|
17
|
+
}
|
|
18
|
+
if (value instanceof RegExp) {
|
|
19
|
+
return new RegExp(value.source, value.flags);
|
|
20
|
+
}
|
|
21
|
+
if (value instanceof Map) {
|
|
22
|
+
const result = new Map();
|
|
23
|
+
for (const [k, v] of value) {
|
|
24
|
+
result.set(cloneValue(k), cloneValue(v));
|
|
25
|
+
}
|
|
26
|
+
return result;
|
|
27
|
+
}
|
|
28
|
+
if (value instanceof Set) {
|
|
29
|
+
const result = new Set();
|
|
30
|
+
for (const v of value) {
|
|
31
|
+
result.add(cloneValue(v));
|
|
32
|
+
}
|
|
33
|
+
return result;
|
|
34
|
+
}
|
|
35
|
+
// Plain object
|
|
36
|
+
const result = {};
|
|
37
|
+
for (const key of Object.keys(value)) {
|
|
38
|
+
result[key] = cloneValue(value[key]);
|
|
39
|
+
}
|
|
40
|
+
return result;
|
|
41
|
+
};
|
|
42
|
+
/**
|
|
43
|
+
* Creates a deep clone of the given value.
|
|
44
|
+
*
|
|
45
|
+
* @param value - The value to deep clone.
|
|
46
|
+
* @returns A deep clone of the input value.
|
|
47
|
+
*
|
|
48
|
+
* @example
|
|
49
|
+
* ```typescript
|
|
50
|
+
* const original = { a: 1, b: { c: 2 } };
|
|
51
|
+
* const cloned = deepClone(original);
|
|
52
|
+
* cloned.b.c = 99;
|
|
53
|
+
* original.b.c; // still 2
|
|
54
|
+
* ```
|
|
55
|
+
*/
|
|
56
|
+
export const deepClone = (value) => {
|
|
57
|
+
if (value === null || typeof value !== "object") {
|
|
58
|
+
return value;
|
|
59
|
+
}
|
|
60
|
+
return cloneValue(value);
|
|
61
|
+
};
|
|
62
|
+
//# sourceMappingURL=deepClone.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"deepClone.js","sourceRoot":"","sources":["../../src/Object/deepClone.ts"],"names":[],"mappings":"AAAA;;GAEG;AACH,MAAM,UAAU,GAAG,CAAC,KAAc,EAAW,EAAE;IAC7C,IAAI,KAAK,KAAK,IAAI,IAAI,OAAO,KAAK,KAAK,QAAQ,EAAE,CAAC;QAChD,OAAO,KAAK,CAAC;IACf,CAAC;IAED,IAAI,KAAK,CAAC,OAAO,CAAC,KAAK,CAAC,EAAE,CAAC;QACzB,MAAM,MAAM,GAAc,EAAE,CAAC;QAC7B,KAAK,MAAM,OAAO,IAAI,KAAK,EAAE,CAAC;YAC5B,MAAM,CAAC,IAAI,CAAC,UAAU,CAAC,OAAO,CAAC,CAAC,CAAC;QACnC,CAAC;QACD,OAAO,MAAM,CAAC;IAChB,CAAC;IAED,IAAI,KAAK,YAAY,IAAI,EAAE,CAAC;QAC1B,OAAO,IAAI,IAAI,CAAC,KAAK,CAAC,CAAC;IACzB,CAAC;IAED,IAAI,KAAK,YAAY,MAAM,EAAE,CAAC;QAC5B,OAAO,IAAI,MAAM,CAAC,KAAK,CAAC,MAAM,EAAE,KAAK,CAAC,KAAK,CAAC,CAAC;IAC/C,CAAC;IAED,IAAI,KAAK,YAAY,GAAG,EAAE,CAAC;QACzB,MAAM,MAAM,GAAG,IAAI,GAAG,EAAE,CAAC;QACzB,KAAK,MAAM,CAAC,CAAC,EAAE,CAAC,CAAC,IAAI,KAAK,EAAE,CAAC;YAC3B,MAAM,CAAC,GAAG,CAAC,UAAU,CAAC,CAAC,CAAC,EAAE,UAAU,CAAC,CAAC,CAAC,CAAC,CAAC;QAC3C,CAAC;QACD,OAAO,MAAM,CAAC;IAChB,CAAC;IAED,IAAI,KAAK,YAAY,GAAG,EAAE,CAAC;QACzB,MAAM,MAAM,GAAG,IAAI,GAAG,EAAE,CAAC;QACzB,KAAK,MAAM,CAAC,IAAI,KAAK,EAAE,CAAC;YACtB,MAAM,CAAC,GAAG,CAAC,UAAU,CAAC,CAAC,CAAC,CAAC,CAAC;QAC5B,CAAC;QACD,OAAO,MAAM,CAAC;IAChB,CAAC;IAED,eAAe;IACf,MAAM,MAAM,GAA4B,EAAE,CAAC;IAC3C,KAAK,MAAM,GAAG,IAAI,MAAM,CAAC,IAAI,CAAC,KAAgC,CAAC,EAAE,CAAC;QAChE,MAAM,CAAC,GAAG,CAAC,GAAG,UAAU,CAAE,KAAiC,CAAC,GAAG,CAAC,CAAC,CAAC;IACpE,CAAC;IACD,OAAO,MAAM,CAAC;AAChB,CAAC,CAAC;AAEF;;;;;;;;;;;;;GAaG;AACH,MAAM,CAAC,MAAM,SAAS,GAAG,CAAI,KAAQ,EAAK,EAAE;IAC1C,IAAI,KAAK,KAAK,IAAI,IAAI,OAAO,KAAK,KAAK,QAAQ,EAAE,CAAC;QAChD,OAAO,KAAK,CAAC;IACf,CAAC;IACD,OAAO,UAAU,CAAC,KAAK,CAAM,CAAC;AAChC,CAAC,CAAC"}
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Extract key-value pairs common to all input objects.
|
|
3
|
+
*
|
|
4
|
+
* A key-value pair is considered common when the key exists in every object
|
|
5
|
+
* and the value is strictly equal (===) across all objects.
|
|
6
|
+
* When all values for a key are plain objects, the function recurses to find
|
|
7
|
+
* the common subset. If the recursive result is empty, the key is excluded.
|
|
8
|
+
*
|
|
9
|
+
* @template T - Type of the input objects.
|
|
10
|
+
* @param {T} object - The first object.
|
|
11
|
+
* @param {...Record<string, unknown>[]} objects - Additional objects to compare.
|
|
12
|
+
* @returns {Partial<T>} Object containing only the key-value pairs shared by all inputs.
|
|
13
|
+
*
|
|
14
|
+
* @example
|
|
15
|
+
* ```typescript
|
|
16
|
+
* getObjectsCommon({ a: 1, b: 2 }, { a: 1, c: 3 });
|
|
17
|
+
* // { a: 1 }
|
|
18
|
+
*
|
|
19
|
+
* getObjectsCommon({ a: { b: 1, c: 2 }, d: 3 }, { a: { b: 1, d: 4 }, d: 3 });
|
|
20
|
+
* // { a: { b: 1 }, d: 3 }
|
|
21
|
+
* ```
|
|
22
|
+
*/
|
|
23
|
+
export declare const getObjectsCommon: <T extends Record<string, unknown>>(object: T, ...objects: Record<string, unknown>[]) => Partial<T>;
|
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
import { isPlainObject } from "../Object/isPlainObject";
|
|
2
|
+
/**
|
|
3
|
+
* Extract key-value pairs common to all input objects.
|
|
4
|
+
*
|
|
5
|
+
* A key-value pair is considered common when the key exists in every object
|
|
6
|
+
* and the value is strictly equal (===) across all objects.
|
|
7
|
+
* When all values for a key are plain objects, the function recurses to find
|
|
8
|
+
* the common subset. If the recursive result is empty, the key is excluded.
|
|
9
|
+
*
|
|
10
|
+
* @template T - Type of the input objects.
|
|
11
|
+
* @param {T} object - The first object.
|
|
12
|
+
* @param {...Record<string, unknown>[]} objects - Additional objects to compare.
|
|
13
|
+
* @returns {Partial<T>} Object containing only the key-value pairs shared by all inputs.
|
|
14
|
+
*
|
|
15
|
+
* @example
|
|
16
|
+
* ```typescript
|
|
17
|
+
* getObjectsCommon({ a: 1, b: 2 }, { a: 1, c: 3 });
|
|
18
|
+
* // { a: 1 }
|
|
19
|
+
*
|
|
20
|
+
* getObjectsCommon({ a: { b: 1, c: 2 }, d: 3 }, { a: { b: 1, d: 4 }, d: 3 });
|
|
21
|
+
* // { a: { b: 1 }, d: 3 }
|
|
22
|
+
* ```
|
|
23
|
+
*/
|
|
24
|
+
export const getObjectsCommon = (object, ...objects) => {
|
|
25
|
+
if (objects.length === 0) {
|
|
26
|
+
return { ...object };
|
|
27
|
+
}
|
|
28
|
+
const result = {};
|
|
29
|
+
for (const [key, value] of Object.entries(object)) {
|
|
30
|
+
let isCommon = true;
|
|
31
|
+
let allPlainObjects = isPlainObject(value);
|
|
32
|
+
for (const other of objects) {
|
|
33
|
+
if (!Object.hasOwn(other, key)) {
|
|
34
|
+
isCommon = false;
|
|
35
|
+
break;
|
|
36
|
+
}
|
|
37
|
+
if (!isPlainObject(other[key])) {
|
|
38
|
+
allPlainObjects = false;
|
|
39
|
+
}
|
|
40
|
+
if (!allPlainObjects && other[key] !== value) {
|
|
41
|
+
isCommon = false;
|
|
42
|
+
break;
|
|
43
|
+
}
|
|
44
|
+
}
|
|
45
|
+
if (!isCommon) {
|
|
46
|
+
continue;
|
|
47
|
+
}
|
|
48
|
+
if (allPlainObjects) {
|
|
49
|
+
const nested = getObjectsCommon(value, ...objects.map((other) => other[key]));
|
|
50
|
+
if (Object.keys(nested).length > 0) {
|
|
51
|
+
result[key] = nested;
|
|
52
|
+
}
|
|
53
|
+
}
|
|
54
|
+
else {
|
|
55
|
+
result[key] = value;
|
|
56
|
+
}
|
|
57
|
+
}
|
|
58
|
+
return result;
|
|
59
|
+
};
|
|
60
|
+
//# sourceMappingURL=getObjectsCommon.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"getObjectsCommon.js","sourceRoot":"","sources":["../../src/Object/getObjectsCommon.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,MAAM,wBAAwB,CAAC;AAEvD;;;;;;;;;;;;;;;;;;;;;GAqBG;AACH,MAAM,CAAC,MAAM,gBAAgB,GAAG,CAC9B,MAAS,EACT,GAAG,OAAkC,EACzB,EAAE;IACd,IAAI,OAAO,CAAC,MAAM,KAAK,CA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