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'. See tests for more examples.
Works in Node, browsers, and on the command line.,
Getting Started
Install node module with: npm install approximate-number
var approx = require('approximate-number');
approx(123456)
Or use the browser module with: bower install approximate-number
<script src="/bower_components/approximate-number/lib/approximate-number.js"></script>
<script>
alert(approximate(1234567890));
</script>
Or install with -g
for command line usage
$ npm install -g approximate-number
$ approximate-number 78910
Contributing
In lieu of a formal styleguide, take care to maintain the existing coding style. Add unit tests for any new or changed functionality. Lint and test your code using Grunt.
License
Copyright (c) 2014 Nathan Friedly
Licensed under the MIT license.