Giter Club home page Giter Club logo

aveta's Introduction


logo

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

Get it on npm

npm install aveta

Get it on yarn

yarn add  aveta

Usage

aveta(value: number, options: IOptions)
import aveta from 'aveta';

// For CommonJS: `const { aveta } = require("aveta");`

aveta(8700); // 8.7K

aveta(123456, {
  digits: 3,
  lowercase: true,
});
// 123k
aveta(4567, {
  digits: 3,
  lowercase: true,
});
// 4.57k
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 MB

Command Line

$ aveta 234000
// or
$ npx aveta 234000
234K

See aveta --help for options.

Default Options

Name Type Default Description
precision number 1 Number of significant digits
digits number 0 Number of 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.


MIT License

Authors

Mhammed Talhaouy

aveta's People

Contributors

tal7aouy avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar

Forkers

devtommy1

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.