DailyJS

DailyJS

The JavaScript blog.


Tagfinance
Featured

libraries node modules ES6 finance

ES6 Features, Open Exchange Rates

Posted on .

ES6 Features

Ralf S. Engelschall has put together a clear and concise site that showcases the major ES6 features: es6-features.org (GitHub: rse/es6-features, License: MIT). It shows a brief example of each feature and compares it to the ES5 equivalent, so you can easily see what you were doing vs. what you could be doing.

Some features don't have direct equivalents in ES5, like symbols and WeakMap/WeakSet, so in that case there's just an ES6 example. The site is open source, so you can provide pull requests for any fixes or additional material.

Ralf is enthusiastic about the improvements ES6 brings, and even though I'm familiar with most of these features the site made me increasingly convinced that we should all be writing ES6 now.

Open Exchange Rates

Why is it whenever you have to do a seemingly simple financial programming task, like checking the validity of a VAT code, or getting the latest exchange rates, it's always so painful? Fortunately, fellow programmers have started to build services to fix these issues. One such service is Open Exchange Rates, which provides real-time and historical rates for 165 currencies.

Amine Mouafik wrote in to say his module, oxr (GitHub: continuous-software/oxr, License: MIT, npm: oxr) has just been selected to be the official Node client.

You'll need an API key to use it. The service has paid and free options, and Amine's module is promise-based:

var oxr = require('oxr').factory;  
var service = oxr({  
  appId: process.env.OXR_APPID
});

service.latest().then(function(result) {  
  var rates = result.rates;
  console.log(rates);
});

You can also cache requests, so you could make it fit in with that free plan's API limit. The next time you're building an online store that supports multiple currencies it might be worth giving this a try.

Amine developed oxr with lorenzofox3, who has some interesting AngularJS modules on GitHub.