Releases: itsmnthn/big-utils
Releases · itsmnthn/big-utils
v2.0.0
Highlights
- Arithmetic: New fixed-point math utilities (
bigMulDivTrunc,bigMulDivRound,bigMulScaled,bigDivScaled,bigSqrtInt,bigSqrtScaled,bigPowIntScaled) with robust rounding viaROUND_MODES. - Scaling: Introduced
bigScale,bigUnscale,bigRescale,bigAlignScalesand compatibility wrappersscale,unScale,unScaleToBase. - Core: Added
bigAbs,bigClamp,bigMin,bigMax,bigGcd,bigPow10,bigSign. - Formatting:
formatWithComma,formatNumberCompact,formatSmallest,shortenDecimals,formatAmount,formatAmountCompact. - Units: Reworked
calcTotalPrice,calcUnitPrice,calcUnits; addedsqrtPricehelpers; improved percentage utilities (calcPercentOf,calcPercentFrom,increaseByPercent,decreaseByPercent,multiplyByFactor,divideByFactor). - Utils: BigInt JSON support (
monkeyPatchBigInt,unPatchBigInt,parseWithBigInt,stringifyWithBigInt), string helpers, timers, ranges, IDs, trimming. - Structure: Clear modules
core,arithmetic,scaling,formatting,units,utils; consolidated constants inutils/zro. - Build: Migrated from unbuild to tsdown; CJS/ESM outputs, DTS, clean builds; updated repo scripts.
Breaking changes
- File and export reorganization: many v1 functions moved into dedicated modules; top-level re-exports preserved via
src/index.tsbut direct deep imports from v1 locations will break. - Removal/renames:
src/formatter.ts,src/units/formatter.ts,src/units/scale.ts,src/units/unscale.ts, and other legacy single-file utilities replaced by modularformatting/andscaling/APIs. - Rounding is explicit for fixed-point helpers: functions like
bigMulScaled,bigDivScaled,bigPowIntScaled, andbigSqrtScaledrequire aROUND_MODESargument where applicable.
Migration guide
Imports
// v1 (old)
// import { scale, unScale } from '@itsmnthn/big-utils/units/scale'
// import { formatWithComma } from '@itsmnthn/big-utils/formatter'
// v2 (new)
import {
// Core math
bigAbs, bigPow10, bigGcd,
// Fixed-point arithmetic
bigMulDivTrunc, bigMulDivRound, bigMulScaled, bigDivScaled, bigSqrtScaled, bigPowIntScaled,
ROUND_MODES,
// Scaling
bigScale, bigUnscale, bigRescale, bigAlignScales, scale, unScale, unScaleToBase,
// Formatting
formatWithComma, formatAmount, formatAmountCompact, formatNumberCompact, formatSmallest, shortenDecimals,
// Units
calcTotalPrice, calcUnitPrice, calcUnits,
// Utils
parseWithBigInt, stringifyWithBigInt, monkeyPatchBigInt, unPatchBigInt,
} from '@itsmnthn/big-utils'Behavioral notes
- Price and percent helpers validate inputs and return
0nfor zero magnitudes where appropriate; invalid arguments throw typed errors (RangeError,TypeError). scale/unScaleremain available for backward compatibility but now delegate to newbig*functions.- Rounding defaults:
bigScaledefaults toHALF_AWAY_ZERO;bigUnscale/bigRescaledefault toTRUNC.
DX and build
- Build:
tsdownwith multi-format output,dts, andexportsmap;engines.nodeset to^22. - Scripts:
build,stub,test,lint,lint:fix,release,prepare. - Package exports: ESM/CJS entry points with types at
dist/.
Tests
- 15 spec files, 292 tests passing.
- Coverage spans arithmetic, scaling, formatting, units, utils, and BigInt JSON.
Changelog (squashed from commits)
- feat: advanced BigInt math and rounding utilities
- feat: BigInt JSON stringify/parse and monkey patching helpers
- feat: compact number formatting and new formatting helpers
- refactor: reorganize exports, regroup features into modules; consolidate constants
- refactor: improve error handling/validation in price and formatting
- refactor: scale/unscale to use bigScale/bigUnscale (backward compatible)
- chore: migrate unbuild → tsdown; update dependencies; ignore docs
Notes
- No runtime deps; all utilities are pure BigInt/TS.
- Docs for v2 to follow; v1 docs remain at
https://big-utils.pages.dev/.
Full Changelog: v1.0.0...v2.0.0