@zooly/util is a shared utility package that provides common helper functions used across multiple packages and apps in the monorepo.
This package is used to shared across client and server packages.
Make sure not to include srv only, or client only code.
@zooly/utilpackages/utilThe package includes utilities for:
File: packages/util/src/utils/currency.ts
Centralized utilities for handling multi-currency amounts, including zero-decimal currencies (e.g. JPY, KRW where 1 minor unit = 1 whole unit):
| Function | Description |
|---|---|
isZeroDecimalCurrency(currency) | Returns true for currencies with no decimal places (JPY, KRW, etc.) |
getMinorUnitMultiplier(currency) | Returns 100 for normal currencies, 1 for zero-decimal |
getDecimalPlaces(currency) | Returns 2 for normal currencies, 0 for zero-decimal |
minorUnitToMajor(amount, currency) | Converts minor units to major: 1000 USD → 10.00, 1000 JPY → 1000 |
majorToMinorUnit(amount, currency) | Converts major to minor units: 10.00 USD → 1000, 1000 JPY → 1000 |
File: packages/util/src/utils/stripe-utils.ts
| Function | Description |
|---|---|
formatMinorUnitToDisplay(amountMinorUnit, currency?) | Formats an amount for display using Intl.NumberFormat with the correct currency symbol and decimal places. Defaults to "USD". |
calculateStripeFees(amountMinorUnit, currency?) | Calculates Stripe processing fees. The fixed fee ($0.30) is set to 0 for zero-decimal currencies. |
@zooly/types for shared typesThis package provides reusable utility functions that can be imported by any package or app in the monorepo, reducing code duplication and ensuring consistency.