Giter VIP home page Giter VIP logo

number-to-words's People

Contributors

marlun78 avatar pilyugin avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar

number-to-words's Issues

Locale

No Locale availables

Add locale (eg : "fr-FR")

It is a shame this lib is only in english !

You should definitely implement a locale for foreign countries

I get isFinite Error

i get this error when trying to convert number to words

TypeError: Not a finite number: undefined (undefined)
at Object.j [as toWords]

Two-way functionality e.g toNumber

Not sure how much work this would take, but a toNumber function that took in a string of cardinal numbers e.g one hundred and five and returned it's number counterpart e.g 105 would be great

Returning incorrect amount in words

For this value 800000000000000000000000
Amount in words is coming SEVEN HUNDRED NINETY-NINE BILLION NINE HUNDRED NINETY-NINE MILLION NINE HUNDRED NINETY-NINE THOUSAND NINE HUNDRED NINETY-NINE TRILLION NINE HUNDRED NINETY-NINE BILLION NINE HUNDRED TWENTY-TWO MILLION SEVENTY-THREE THOUSAND SIX HUNDRED

Return as dataset

Would be great to have the option to get the words as an array so that we can construct our own joining rules easily. E.g.:

converter.toWords(9007199254740992, true); // 'true' to get return as data

Returns:

[
  'nine quadrillion', 
  'seven trillion', 
  'one hundred ninety-nine billion', 
  'two hundred fifty-four million', 
  'seven hundred forty thousand', 
  'nine hundred',
  'ninety-two'
]

Then we can do things like:

let wordsArray = converter.toWords(9007199254740992, true);
let ret1 = `There are over ${wordsArray[0]} available.`; // There are over nine quadrillion available.

or

let wordsArray = converter.toWords(1992, true);
let last = wordsArray.pop()
let ret = 'There are ' + wordsArray.join(' ') + ' and ' + last; // There are one thousand nine hundred and ninety-two

Unexpected ordinal numerals when traversing an array

var numberToWords = require("number-to-words");
const tw = numberToWords.toWords;
[1,4,5,7].map((d) => tw(d));
[1,4,5,7].map(tw);

When the library is used with an implicit passed parameter (second example), every array element except the first is an ordinal numeral:
The result of [1,4,5,7].map((d) => tw(d)); is ["one", "four", "five", "seven"]
The result of [1,4,5,7].map(tw); is: ["one", "fourth", "fifth", "seventh"]

Option for a verbal representation using 'and'

Hi, great module! Perhaps add an option for an 'and' word to be added in certain circumstances. Your module seems the best so far, just an idea for your really.

converter.toWords(40092); // => “forty thousand AND ninety-two”

converter.toWords(20607); // => “twenty thousand six hundred AND seven”

Thanks
Sharry

Cannot use string manipulation methods on converted numbers to words.

I cannot seem to manipulate a number that has been converted to a string, using string methods such as .split(), .replace() or .join().
I'm using TypeScript and React.

Example:

var numberToWords = require('number-to-words');
var id = 1526;
var idWord: string = numberToWords.toWords(id);
idWord.replace(' ', '');
console.log(idWord)    // Returns 'one thousand, five hundred twenty-six' instead of the correct 'onethousand,fivehundredtwenty-six'

Wrong endings for ordinal numbers from 11 to 13

Converter returns ordinal numbers with wrong endings:

converter.toOrdinal(11); // => “11st”
converter.toOrdinal(12); // => “12nd”
converter.toOrdinal(13); // => “13rd”

But should be 11th, 12th, 13th.

ES6 module?

Hi, I've converted this package to an ES6 module and cleaned it up quite a bit. Thought you may want to add a link to the readme for users that need tree shaking, etc.

Ref: master...OmgImAlexis:master

Include and possibility

HEllo,
Can you please enable to the possibility to remove or include the 'and '?

I could do it myself for my project I guess, but I figured other people could benefit from it if the original author publishes it on npm. It should be as simple as adding a bool to the toWords(number,includeAnd) function.

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.