README
Converts numbers into a more human-friendly format, similar to ls
's --human-readable
flag (ls -lh
) or Stack
Overflow's reputation numbers. For example, 123456 becomes '123k'.
Works in Node.js and in browsers.
var approx = require('approximate-number');
console.log(approx(1234));
//> 1.2k
console.log(approx(12345));
//> 12k
console.log(approx(1234, {decimal: false}));
//> 1k
console.log(approx(1234, {decimal: ','}));
//> 1,2k
console.log('My Stack Overflow reputation is %s.', approx(3671, {
min10k: true
}));
//> My Stack Overflow reputation is 3,671.
console.log('The US national debt is %s.', approx(19939034457936, {
prefix: '