-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
move fromExponential to separate package, finish tests, add build, ad…
…d readme
- Loading branch information
Showing
16 changed files
with
7,732 additions
and
185 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,10 +1,8 @@ | ||
|
||
/dist/ | ||
/coverage/ | ||
|
||
# dependencies | ||
node_modules | ||
package-lock.json | ||
|
||
/coverage/ | ||
|
||
# logs | ||
npm-debug.log |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
# pretty-num | ||
|
||
[](https://www.npmjs.org/package/pretty-num) | ||
[](https://bundlephobia.com/result?p=pretty-num) | ||
[](https://travis-ci.com/shrpne/pretty-num) | ||
[](https://coveralls.io/github/shrpne/pretty-num?branch=master) | ||
[](https://github.com/shrpne/pretty-num/blob/master/LICENSE) | ||
|
||
Lightweight module to convert number to a pretty human readable string. | ||
|
||
Includes: | ||
- [from-exponential](https://github.com/shrpne/from-exponential) - remove exponential notation | ||
- [thousands](https://github.com/scurker/thousands) - add thousands separators | ||
- reducePrecision - reduce precision of a meaningful decimal part | ||
- stripZeros - strip unnecessary leading and trailing zeros | ||
|
||
|
||
## Install | ||
|
||
``` | ||
npm install pretty-num | ||
``` | ||
|
||
|
||
## Usage | ||
|
||
```js | ||
import prettyNum from 'pretty-num'; | ||
|
||
prettyNum(12.123e-10); // => '0.0000000012123' | ||
prettyNum(0.00123456, {precision: 3}); // => '0.00123' | ||
prettyNum(12345678.12345, {thousandsSeparator: ' '}); // => '12 345 678.12345' | ||
prettyNum('00123456789.12300e-2', {precision: 3, thousandsSeparator: ' '}); // => '1 234 567.891' | ||
|
||
``` | ||
|
||
|
||
## License | ||
|
||
MIT License |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
import commonjs from 'rollup-plugin-commonjs'; | ||
import resolve from 'rollup-plugin-node-resolve'; | ||
import babel from 'rollup-plugin-babel'; | ||
|
||
export default { | ||
input: 'src/index.js', | ||
plugins: [ | ||
commonjs(), | ||
resolve(), | ||
babel({ | ||
babelrc: false, | ||
presets: [['env', { modules: false }]], | ||
}), | ||
], | ||
output: { | ||
file: 'dist/index.js', | ||
format: 'umd', | ||
name: 'prettyNum', | ||
} | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
import commonjs from 'rollup-plugin-commonjs'; | ||
import resolve from 'rollup-plugin-node-resolve'; | ||
import babel from 'rollup-plugin-babel'; | ||
import { terser } from 'rollup-plugin-terser'; | ||
|
||
export default { | ||
input: 'src/index.js', | ||
plugins: [ | ||
commonjs(), | ||
resolve(), | ||
babel({ | ||
babelrc: false, | ||
presets: [['env', { modules: false }]], | ||
}), | ||
terser(), // uglifyjs alternative with es6 support | ||
], | ||
output: { | ||
file: 'dist/index.min.js', | ||
format: 'umd', | ||
name: 'prettyNum', | ||
} | ||
}; |
Oops, something went wrong.