GithubHelp home page GithubHelp logo

largenum's Introduction

Largenum

Build Status Coverage Status

Transforms large numbers into more easily digestible english.

Usage

const {largenum} = require('largenum');

console.log(largenum(64e63));
// '64 vigintillion'

console.log(largenum(1e100));
// '1 googol'

console.log(largenum(1e100, {exclusions: [1e100]}));
// '10 duotrigintillion'

console.log(largenum(14e63, {max: 1e12}));
// '14 thousand trillion trillion trillion trillion trillion'

console.log(largenum(22e6, {threshold: 1e9}));
// '22,000,000'

Options

largenum accepts an options object as its second parameter. The available options are as follows.

Option Default Description
max undefined Sets the largest allowed name to be used. If you wanted to limit conversions to use trillions as the largest unit, you would pass max: 1e12. This would make 1e30 convert to "1 million trillion trillion" instead of "1 nonillion".
threshold undefined Sets the lower limit for where conversions will be applied at all. Numbers below the threshold will convert to digits with thousands separators (i.e. 1e6 will convert to "1,000,000" if you have threshold set to at least 1e6 + 1).
exclusions [] Exclude any names you dont want to be used. To exclude the googol, for example, you would include 1e100 in the list.

largenum's People

Contributors

dependabot[bot] avatar fiso avatar

Stargazers

 avatar  avatar

Watchers

 avatar  avatar  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.