2.0.0 • Published 8 months ago

madnum v2.0.0

Weekly downloads
-
License
MIT
Repository
github
Last release
8 months ago

Madnum

Transform large numbers to length-friendly string

The transform algorithm uses the "aa" notation

import { mn } from 'madnum'

// Default usage

mn(1000) // 1 K
mn(1e6) // 1 M
mn(1.5e6) // 1.5 M

// The "aa" notation example

mn(1e15) // 1 AA

// With fixed precision

mn(1000, 2) // 1.00 K
mn(1.2324e6, 3) // 1.232 M

// With options

mn(-123114511661, {
  format: '{num}{unit}',
  maxfd: 2,
  lowercase: true,
  separator: ' '
}) // -123.11b

// Can handle infinity-like numbers

mn(1e1000) // ∞
mn(Infinity) // ∞
mn(-Infinity) // -∞