Skip to content

alyshukry/numerica

Repository files navigation

numerica logo

A utility library for number formatting.
String-to-number parsing coming soon.


Navigation

  1. Documentation
  2. Contributing
  3. License

Installation

Javascript:

npm  install  numerica
import  from  "numerica"

Examples

toAbbreviated(12345, { d: 1 }) // Returns "12.3k"
toAbbreviated(1000000) // Returns "1m"
toWords(12345, { and: true, hyphen: true }) // Returns "twelve thousand three hundred and forty-five"
toWords(54321, { space: "_" }) // Returns "fifty four thousand three hundred twenty one"
toRelativeTime(new Date(Date.now() - (DAY + HOUR + MINUTE)), { lod: 3, separator: ' • ' }) // Returns "1 day • 1 hour • 1 minute ago"
toRelativeTime(new Date(Date.now() - 1000)) // Returns "just now"
toGrouped(12345, { segment: 3, char: "." }) // Returns "12.345"
toGrouped(0100100001101001, { segment: 8, char: " " }) // Returns "01001000 01101001"
toFraction(2.5, { mixed: true, pretty: true }) // Returns "2 1⁄2"
toFraction(2.5, { symbol: "|" }) // Returns "5|2"
toBase("HELLO", 36, { from: 10}) // Returns "1495338607"
toBase(123, 10, { from: 2}) // Returns "1111011"

About

A utility library for number formatting.

Topics

Resources

License

Contributing

Stars

Watchers

Forks

Packages

No packages published

Contributors 4

  •  
  •  
  •  
  •