freeall / currency-codes

Node.js module to work with currency codes based on ISO 4217
MIT License
150 stars 56 forks source link

Cannot lookup AUD by number #20

Open swansontec opened 5 years ago

swansontec commented 5 years ago

If I do number(36), I get undefined, not AUD.

This is because the number lookup uses string comparisons, and there is a leading zero in the currency code.

I can work around this by doing: number(('000' + code).slice(-3)), which inserts the leading zeros as needed. This logic should probably move into the library itself.

freeall commented 5 years ago

The number is always a three digit/character long string. So it would be cc.number('036'). Right now I can't remember why I chose this in the first place. I can see that the documentation does not reflect this totally though.

freeall commented 5 years ago

And yeah, it would probably be nice to move this logic into the library. So that it would check if it gets an integer so that cc.number(36) is the same a cc.number('036')

ronkorving commented 3 years ago

@freeall Do you still accept PRs to improve this library? I'm considering contributions, including a fix for this.

If you need help maintaining this repo and NPM package, I'm also happy to volunteer as a maintainer.

ronkorving commented 3 years ago

^ There's my first contribution, if you'll have it :)