Package Exports
- aveta
- aveta/build/aveta.js
This package does not declare an exports field, so the exports above have been automatically detected and optimized by JSPM instead. If any package subpath is missing, it is recommended to post an issue to the original package (aveta) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.
Readme
Convert long numbers into abbreviated and human-readable strings on an easy way.
| Input 😞 | Value 😂 |
|---|---|
6000 |
'6K' |
10000 |
'10km' |
42500 |
'42.5 kg' |
1250000 |
'1.25 MB' |
Install
npm install avetayarn add avetaUsage
aveta(value: number, options: IOptions)import aveta from 'aveta';
// For CommonJS: `const { aveta } = require("aveta");`
aveta(8700); // 8.7K
aveta(2048000, {
precision: 2,
lowercase: true,
});
// 2.48m
aveta(45500, {
precision: 3,
separator: ',',
});
// 4,550K
aveta(1440000, {
units: ['B', 'KB', 'MB', 'GB', 'TB'],
space: true,
});
// 1.44 MBDefault Options
| Name | Type | Default | Description |
|---|---|---|---|
precision |
number |
1 |
Number of significant digits |
separator |
string |
'.' |
Desired decimal separator (e.g. decimal point or comma) |
lowercase |
boolean |
false |
Use lowercase abbreviations |
space |
boolean |
false |
Add a space between number and abbreviation |
units |
Array<string> |
['', 'K', 'M', 'B', 'T', 'P', 'E'] |
Unit abbreviations |
Units
aveta allows you custom your own units for your project.
That is amazing aveta ! 😂