hrn
hrn is short for Human Readable Number, a simple javascript for browserjs / nodejs library to format number into human-readable string.
1. Install
npm install --save hrn
2. Import It
var hrn = ; //or ;
3. Usage & API
There is only one API named hrn(number, fixed, formatter)
.
; // '1.2 M'; // '1.234 M'; // '1.234 M'; // '1.23 万', `en` / `zh_CN` supported, `en` is default.
You can customize the number formatter.
// format numbervar formatter = 'kmgtpezy' 1e3; // '1.2 m' // format time diffformatter = 's' 'm' 'h' 'd' 1 60 60 24;; // '23.0 s' -> 23 seconds; // '23.0 m' -> 23 minutes; // '23.0 h' -> 23 hours; // '23.0 d' -> 23 days
4. Test
npm install
npm test
5. LICENSE
MIT@hustcc