Coder Social home page Coder Social logo

jxshco / small-number Goto Github PK

View Code? Open in Web Editor NEW
2.0 2.0 0.0 65 KB

Easily turn large values into their corresponding number and letter value - 1,300,000 -> 1.3m

License: MIT License

JavaScript 100.00%
number small thousands millions numbers-to-text javascript es6

small-number's Introduction

small-number

travis npm version npm downloads Standard - JavaScript Style Guide

Easily turn large values into their corresponding number and letter value - 1,300,000 -> 1.3m

Why?

While working on freelance/agency work I would tend to come across situations where this was needed. I re-wrote this script each and every time I had a project that needed it, each being different, better and worse.

Table of Contents

Install

Add small-number to your project using npm or yarn.

Install (NPM):

$ npm install small-number --save

Install (Yarn):

$ yarn add small-number

Usage

Import SmallNumber into Your Project

import SmallNumber from 'small-number'

Use Small Number

smallNumber(123456)
// 123.5k

smallNumber(123456, 0)
// 124k

smallNumber(123456, 2)
// 123.46k

let messages = 9831324
let message = `You have ${smallNumber(messages)} unread emails`
//You have 9.8m unread emails

Contributing

Pull requests for new features, bug fixes, and suggestions are welcome!

License

MIT

small-number's People

Contributors

greenkeeper[bot] avatar jxshco avatar

Stargazers

 avatar  avatar

Watchers

 avatar  avatar

small-number's Issues

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.