@leather.io/utils
Advanced tools
| > @leather.io/utils@0.46.2 build /home/runner/work/mono/mono/packages/utils | ||
| > @leather.io/utils@0.46.3 build /home/runner/work/mono/mono/packages/utils | ||
| > tsup | ||
@@ -11,7 +11,7 @@ | ||
| [34mESM[39m Build start | ||
| [32mESM[39m [1mdist/index.js [22m[32m73.21 KB[39m | ||
| [32mESM[39m [1mdist/index.js.map [22m[32m138.83 KB[39m | ||
| [32mESM[39m ⚡️ Build success in 31ms | ||
| [32mESM[39m [1mdist/index.js [22m[32m73.03 KB[39m | ||
| [32mESM[39m [1mdist/index.js.map [22m[32m138.46 KB[39m | ||
| [32mESM[39m ⚡️ Build success in 36ms | ||
| [34mDTS[39m Build start | ||
| [32mDTS[39m ⚡️ Build success in 2338ms | ||
| [32mDTS[39m [1mdist/index.d.ts [22m[32m14.88 KB[39m | ||
| [32mDTS[39m ⚡️ Build success in 2493ms | ||
| [32mDTS[39m [1mdist/index.d.ts [22m[32m14.79 KB[39m |
+7
-0
@@ -355,2 +355,9 @@ # Changelog | ||
| ### Dependencies | ||
| * The following workspace dependencies were updated | ||
| * dependencies | ||
| * @leather.io/constants bumped to 0.27.0 | ||
| * @leather.io/models bumped to 0.44.0 | ||
| ## [0.46.0](https://github.com/leather-io/mono/compare/@leather.io/utils-v0.45.0...@leather.io/utils-v0.46.0) (2025-09-26) | ||
@@ -357,0 +364,0 @@ |
+1
-3
@@ -51,4 +51,2 @@ import BigNumber, { BigNumber as BigNumber$1 } from 'bignumber.js'; | ||
| declare function isValidPrecision(amount: number, precision: number): boolean; | ||
| declare function unitToFractionalUnit(decimals: number): (unit: number | string | BigNumber) => BigNumber; | ||
@@ -289,2 +287,2 @@ declare const satToBtc: (unit: number | string | BigNumber) => BigNumber; | ||
| export { type CreateInscriptionData, type FormatAmountOptions, type SerializedCryptoAssetId, aggregateBaseCryptoAssetBalances, aggregateBtcBalances, aggregateStxBalances, assertExistence, assertIsTruthy, assertUnreachable, baseCurrencyAmountInQuote, baseCurrencyAmountInQuoteWithFallback, btcToSat, calculateMeanAverage, capitalize, convertAmountToBaseUnit, convertAmountToFractionalUnit, convertToMoneyTypeWithDefaultOfZero, countDecimals, createAccountAddresses, createBaseCryptoAssetBalance, createBtcBalance, createCounter, createCurrencyFormatter, createInscriptionAsset, createMoney, createMoneyFromDecimal, createNullArrayOfLength, createNumArrayOfRange, createStxBalance, dateToUnixTimestamp, daysInMs, daysInSec, defaultWalletKeyId, delay, deserializeAssetId, ensureArray, extractPhraseFromString, fibonacciGenerator, fiveMinInMs, flattenObject, getAssetDisplayName, getAssetId, getTicker, hasBitcoinAddress, hasStacksAddress, hexToNumber, hoursInMs, hoursInSec, increaseValueByOneMicroStx, initBigNumber, invertExchangeRate, isBigInt, isBoolean, isDefined, isEmpty, isEmptyArray, isEmptyString, isError, isEven, isFiatCurrencyCode, isFulfilled, isFunction, isHexString, isMoney, isMoneyGreaterThanZero, isNumber, isNumberOrNumberList, isObject, isRejected, isSameAsset, isSameAssetId, isString, isTypedArray, isUndefined, isValidPrecision, makeNumberRange, makeStacksTxExplorerLink, mapObject, match, matchesAssetId, maxMoney, microStxToStx, migratePositiveAssetBalancesToTop, minMoney, minutesInMs, minutesInSec, moneyToBaseUnit, noop, oneDayInMs, oneMinInMs, oneWeekInMs, propIfDefined, pxStringToNumber, quoteCurrencyAmountToBase, rebaseMarketData, removeTrailingNullCharacters, reverseBytes, safelyFormatHexTxid, sanitizeContent, satToBtc, scaleValue, secondsInMs, serializeAssetId, sortAssetsByName, spamFilter, stxToMicroStx, subtractMoney, sumMoney, sumNumbers, toHexString, truncateMiddle, undefinedIfLengthZero, uniqueArray, unitToFractionalUnit, weeksInMs, weeksInSec, whenInscriptionMimeType, whenNetwork }; | ||
| export { type CreateInscriptionData, type FormatAmountOptions, type SerializedCryptoAssetId, aggregateBaseCryptoAssetBalances, aggregateBtcBalances, aggregateStxBalances, assertExistence, assertIsTruthy, assertUnreachable, baseCurrencyAmountInQuote, baseCurrencyAmountInQuoteWithFallback, btcToSat, calculateMeanAverage, capitalize, convertAmountToBaseUnit, convertAmountToFractionalUnit, convertToMoneyTypeWithDefaultOfZero, countDecimals, createAccountAddresses, createBaseCryptoAssetBalance, createBtcBalance, createCounter, createCurrencyFormatter, createInscriptionAsset, createMoney, createMoneyFromDecimal, createNullArrayOfLength, createNumArrayOfRange, createStxBalance, dateToUnixTimestamp, daysInMs, daysInSec, defaultWalletKeyId, delay, deserializeAssetId, ensureArray, extractPhraseFromString, fibonacciGenerator, fiveMinInMs, flattenObject, getAssetDisplayName, getAssetId, getTicker, hasBitcoinAddress, hasStacksAddress, hexToNumber, hoursInMs, hoursInSec, increaseValueByOneMicroStx, initBigNumber, invertExchangeRate, isBigInt, isBoolean, isDefined, isEmpty, isEmptyArray, isEmptyString, isError, isEven, isFiatCurrencyCode, isFulfilled, isFunction, isHexString, isMoney, isMoneyGreaterThanZero, isNumber, isNumberOrNumberList, isObject, isRejected, isSameAsset, isSameAssetId, isString, isTypedArray, isUndefined, makeNumberRange, makeStacksTxExplorerLink, mapObject, match, matchesAssetId, maxMoney, microStxToStx, migratePositiveAssetBalancesToTop, minMoney, minutesInMs, minutesInSec, moneyToBaseUnit, noop, oneDayInMs, oneMinInMs, oneWeekInMs, propIfDefined, pxStringToNumber, quoteCurrencyAmountToBase, rebaseMarketData, removeTrailingNullCharacters, reverseBytes, safelyFormatHexTxid, sanitizeContent, satToBtc, scaleValue, secondsInMs, serializeAssetId, sortAssetsByName, spamFilter, stxToMicroStx, subtractMoney, sumMoney, sumNumbers, toHexString, truncateMiddle, undefinedIfLengthZero, uniqueArray, unitToFractionalUnit, weeksInMs, weeksInSec, whenInscriptionMimeType, whenNetwork }; |
+3
-3
@@ -5,3 +5,3 @@ { | ||
| "description": "Shared bitcoin utilities", | ||
| "version": "0.46.2", | ||
| "version": "0.46.3", | ||
| "license": "MIT", | ||
@@ -23,4 +23,4 @@ "homepage": "https://github.com/leather-io/mono/tree/dev/packages/utils", | ||
| "dompurify": "3.2.4", | ||
| "@leather.io/constants": "0.26.0", | ||
| "@leather.io/models": "0.43.0" | ||
| "@leather.io/constants": "0.27.0", | ||
| "@leather.io/models": "0.44.0" | ||
| }, | ||
@@ -27,0 +27,0 @@ "devDependencies": { |
@@ -5,3 +5,2 @@ export * from './calculate-money'; | ||
| export * from './is-fiat-currency-code'; | ||
| export * from './is-valid-precision'; | ||
| export * from './unit-conversion'; |
| import { currencyDecimalsMap } from '@leather.io/constants'; | ||
| import { isValidPrecision } from './is-valid-precision'; | ||
| describe('isValidPrecision', () => { | ||
| it('returns true for a valid precision', () => { | ||
| expect(isValidPrecision(10.12, currencyDecimalsMap.USD)).toBe(true); | ||
| expect(isValidPrecision(10.123456, currencyDecimalsMap.STX)).toBe(true); | ||
| expect(isValidPrecision(10.12345678, currencyDecimalsMap.BTC)).toBe(true); | ||
| }); | ||
| it('returns false for an invalid precision', () => { | ||
| expect(isValidPrecision(10.122, currencyDecimalsMap.USD)).toBe(false); | ||
| expect(isValidPrecision(10.1234567, currencyDecimalsMap.STX)).toBe(false); | ||
| expect(isValidPrecision(10.123456789, currencyDecimalsMap.BTC)).toBe(false); | ||
| }); | ||
| it('returns true for a valid precision with a whole number', () => { | ||
| expect(isValidPrecision(10, currencyDecimalsMap.USD)).toBe(true); | ||
| expect(isValidPrecision(10, currencyDecimalsMap.STX)).toBe(true); | ||
| expect(isValidPrecision(10, currencyDecimalsMap.BTC)).toBe(true); | ||
| }); | ||
| }); |
| import { isNumber } from '../index'; | ||
| import { countDecimals } from '../math'; | ||
| export function isValidPrecision(amount: number, precision: number) { | ||
| if (!isNumber(amount)) return false; | ||
| return countDecimals(amount) <= precision; | ||
| } |
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is too big to display
Long strings
Supply chain riskContains long string literals, which may be a sign of obfuscated or packed code.
Found 1 instance in 1 package
URL strings
Supply chain riskPackage contains fragments of external URLs or IP addresses, which the package may be accessing at runtime.
Found 1 instance in 1 package
Long strings
Supply chain riskContains long string literals, which may be a sign of obfuscated or packed code.
Found 1 instance in 1 package
URL strings
Supply chain riskPackage contains fragments of external URLs or IP addresses, which the package may be accessing at runtime.
Found 1 instance in 1 package
416508
-0.43%59
-3.28%9171
-0.36%+ Added
+ Added
- Removed
- Removed
Updated
Updated