Skip to content

Commit

Permalink
move fromExponential to separate package, finish tests, add build, ad…
Browse files Browse the repository at this point in the history
…d readme
  • Loading branch information
shrpne committed Jul 31, 2018
1 parent 0a1bc33 commit 457776b
Show file tree
Hide file tree
Showing 16 changed files with 7,732 additions and 185 deletions.
6 changes: 2 additions & 4 deletions .gitignore
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
40 changes: 40 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
# pretty-num

[![NPM Package](https://img.shields.io/npm/v/pretty-num.svg?style=flat-square)](https://www.npmjs.org/package/pretty-num)
[![Minified Size](https://img.shields.io/bundlephobia/min/pretty-num.svg?style=flat-square)](https://bundlephobia.com/result?p=pretty-num)
[![Build Status](https://img.shields.io/travis/com/shrpne/pretty-num/master.svg?style=flat-square)](https://travis-ci.com/shrpne/pretty-num)
[![Coverage Status](https://img.shields.io/coveralls/github/shrpne/pretty-num/master.svg?style=flat-square)](https://coveralls.io/github/shrpne/pretty-num?branch=master)
[![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg?style=flat-square)](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
20 changes: 20 additions & 0 deletions build/rollup.config.js
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',
}
};
22 changes: 22 additions & 0 deletions build/rollup.uglify.config.js
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',
}
};
Loading

0 comments on commit 457776b

Please sign in to comment.