Giter Site home page Giter Site logo

wberredo / numscale Goto Github PK

View Code? Open in Web Editor NEW

This project forked from mharsch/numscale

0.0 1.0 0.0 6 KB

A Node.js module for converting numbers into pretty strings with suffixes indicating order of magnitude

License: MIT License

JavaScript 100.00%

numscale's Introduction

#numscale.js

A Node.js module for converting numbers into pretty strings with suffixes to indicate scale (Kilo, Mega, Giga, etc.)

##Examples:

>var ns = require('numscale');
>var myThroughput = {value: 1000000000, powerOf: 10, maxLen: 5};
>ns.scale(myThroughput)
'1G'

>var myCapacity = {value: 1073741824, powerOf: 2, maxLen: 5};
>ns.scale(myCapacity)
'1G'

>var myCounter = {value: 654345443, powerOf: 10, maxLen: 6};
>ns.scale(myCounter)
'654.3M'

>var myMemory = {value: 43322466, powerOf: 2, maxLen: 7};
>ns.scale(myMemory)
'41.316M'

##Usage:

The scale() method takes an object argument. The members of the argument object are as follows:

  • value (required) - the number to be scaled and formatted
  • powerOf (optional) - either 2 or 10: sets scaling factor (defaults to 10)
  • maxLen (optional) - maximum length of the string to be returned (default 20)

'value' must be a non-negative positive integer within the safe JavaScript range.

numscale's People

Contributors

mharsch avatar

Watchers

James Cloos avatar

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.