sky-numeral
v1.0.0
Published
A javascript library for formatting and manipulating numbers.
Downloads
2
Readme
sky-numeral
A javascript library for formatting and manipulating numbers.
Features
- arbitrary-precision decimal
- 8 Rounding Mode
- support keep significant digit
Use
import numeral from "sky-numeral";
// Thousand place comma
console.log(numeral('12312.2365').format('0,0')); //12,312
// Percentage
console.log(numeral('1').format('0%')); //100%
// Thousand place comma and percentage
console.log(numeral('12312.2365').format('0,0%')); //1,231,223%
// Rounding Mode
console.log(numeral('1.15').format('0.0', Math.ceil)); //1.2
console.log(numeral('-1.15').format('0.0', Math.ceil)); //-1.1
console.log(numeral('1.15').format('0.0', Math.floor)); //1.1
console.log(numeral('-1.15').format('0.0', Math.floor)); //-1.2
// keep significant digit
console.log((numeral('12312.2').format('0,0.00~', Math.trunc)); //12,312.20
console.log((numeral('12312.2123').format('0,0.00~', Math.trunc)); //12,312.2123