PATH:
usr
/
local
/
lib
/
node_modules
/
bower
/
lib
/
node_modules
/
mout
/
number
var enforcePrecision = require('./enforcePrecision'); var _defaultDict = { thousand : 'K', million : 'M', billion : 'B' }; /** * Abbreviate number if bigger than 1000. (eg: 2.5K, 17.5M, 3.4B, ...) */ function abbreviateNumber(val, nDecimals, dict){ nDecimals = nDecimals != null? nDecimals : 1; dict = dict || _defaultDict; val = enforcePrecision(val, nDecimals); var str, mod; if (val < 1000000) { mod = enforcePrecision(val / 1000, nDecimals); // might overflow to next scale during rounding str = mod < 1000? mod + dict.thousand : 1 + dict.million; } else if (val < 1000000000) { mod = enforcePrecision(val / 1000000, nDecimals); str = mod < 1000? mod + dict.million : 1 + dict.billion; } else { str = enforcePrecision(val / 1000000000, nDecimals) + dict.billion; } return str; } module.exports = abbreviateNumber;
[-] MAX_INT.js
[edit]
[-] toInt.js
[edit]
[+]
..
[-] MAX_SAFE_INTEGER.js
[edit]
[-] nth.js
[edit]
[-] sign.js
[edit]
[-] toUInt31.js
[edit]
[-] pad.js
[edit]
[-] rol.js
[edit]
[-] MAX_UINT.js
[edit]
[-] enforcePrecision.js
[edit]
[-] isNaN.js
[edit]
[-] abbreviate.js
[edit]
[-] currencyFormat.js
[edit]
[-] toUInt.js
[edit]
[-] MIN_INT.js
[edit]
[-] ordinal.js
[edit]
[-] ror.js
[edit]