@zenuinebit/money
v0.1.0
Published
Integer minor-unit money math: conversion, formatting, exact allocation, cash rounding. Zero dependencies.
Readme
@zenuinebit/money
Money as integers in minor units (cents, paise). No floats, no dependencies.
import { toMinor, format, allocate, split, roundToIncrement } from "@zenuinebit/money";
toMinor(1.005, "USD"); // 101
format(123456, "USD"); // "$1,234.56"
allocate(100, [1, 1, 1]); // [34, 33, 33], always sums to 100
split(1000, 3); // [334, 333, 333]
roundToIncrement(1232, 5); // 1230 (cash rounding)Currency digits come from Intl (JPY has 0, KWD has 3), and rounding is half away from zero.
