https://github.com/thomwright/format-si-prefix
Format and unformat numbers with SI prefixes
https://github.com/thomwright/format-si-prefix
Last synced: 11 days ago
JSON representation
Format and unformat numbers with SI prefixes
- Host: GitHub
- URL: https://github.com/thomwright/format-si-prefix
- Owner: ThomWright
- License: mit
- Created: 2015-10-31T23:25:46.000Z (over 9 years ago)
- Default Branch: master
- Last Pushed: 2021-07-28T14:23:11.000Z (almost 4 years ago)
- Last Synced: 2025-05-07T21:05:23.920Z (11 days ago)
- Language: JavaScript
- Size: 12.7 KB
- Stars: 7
- Watchers: 2
- Forks: 1
- Open Issues: 1
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# format-si-prefix
[](https://www.npmjs.com/package/format-si-prefix)
[](https://david-dm.org/ThomWright/format-si-prefix)
[](https://david-dm.org/ThomWright/format-si-prefix#info=devDependencies)Format and unformat numbers with SI prefixes.
# API
## `formatSI()`
```javascript
import {formatSI} from 'format-si-prefix';
const string = formatSI(number);
```| in | out |
| ------------- | -------:|
| ... | ... |
| 0.000111111 | 111µ |
| 0.00111 | 1.11m |
| 0.0111 | 11.1m |
| 0.111 | 111m |
| 1 | 1 |
| 11 | 11 |
| 111 | 111 |
| 1111 | 1.11k |
| 11111 | 11.1k |
| 111111 | 111k |
| 1111111 | 1.11M |
| ... | ... |## `unformatSI()`
```javascript
import {unformatSI} from 'format-si-prefix';
const number = unformatSI(string);
```| in | out |
| ------- | ------------: |
| ... | ... |
| 111µ | 0.000111 |
| 1.11m | 0.00111 |
| 11.1m | 0.0111 |
| 111m | 0.111 |
| 1 | 1 |
| 11 | 11 |
| 111 | 111 |
| 1.11k | 1110 |
| 11.1k | 11100 |
| 111k | 111000 |
| 1.11M | 1110000 |
| ... | ... |
| 12.345M | 12345000 |
| 12.345 | 12.345 |
| 1234567 | 1234567 |
| 123456M | 123456000000 |
| 1000.1m | 1.0001 |
| ... | ... |# License
[MIT](./LICENSE)