3 ms·
Cashify – a lightweight currency conversion library and Money.js alternative
- dna_polymerase 7y agoIt advertises 0 dependencies? Really? It's 86 lines of code and really boils down to 1: "return amount * getRate({base, rates, from, to});". A fucking multiplication. Who needs a library for this anyway? JavaScript and its ecosystem is a joke.
- davidandgoliath 7y agoGet over yourself.
- dang 7y agoPersonal attacks aren't ok here, regardless of the comment you're replying to. Would you mind reviewing https://news.ycombinator.com/newsguidelines.html https://news.ycombinator.com/newsguidelines.html and sticking to the rules when posting here? Note that they ask you not to reply to egregious comments, but rather to flag them.
- dhritzkiv 7y agoWhy so sour? It's a decently documented and tested utility library that's really closer to 35 SLOC, and is useful for those that would prefer not to write the multiplication logic, as simple as it may seem. You're free to roll your own JS utility function that performs this multiplication. Personally, I don't know why this is on HN as it's not an exceptional utility, and doesn't handle common currency manipulation frustrations (floating point rounding, bigint, decimal formatting, signs, etc.)
- dchest 7y agoThe funny thing is that the example in README shows that this library works incorrectly: EUR: 1.00 GBP: 0.92 const result = cashify.convert(10, {from: 'EUR', to: 'GBP'}); console.log(result); //=> 9.200000000000001 The correct result is 9.2. Due to IEEE floating point precision quirk, the library gives 9.200000000000001.
- STRML 7y agoAnd in fact, something called "money.js" - or the successor to money.js - ought to be able to properly round decimals such that floating point error never becomes the developer's concern.