Skip to content

Currency

Immutable, float-safe, and tree-shakeable. Built on minor-unit integers.

Quick look ​

ts
import { from, sum, total } from '@eriveltondasilva/currency'

// Create
const price = from(19.99, 'BR')
price.format() // => 'R$ 19,99'
price.applyDiscount(10).format() // => 'R$ 17,99'

// Collect
sum([10, 20, 30], 'US').format() // => '$60.00'

// Business
const items = [
  { price: 9.99, quantity: 3 },
  { price: 4.99 },
]
total(items, 'US').format() // => '$34.96'