Get two letter continent code from ip address with JavaScript/Node.js

I'm writing a JavaScript/Node.js application that needs to place items in a continent based on an IP address I receive. PHP has a geoip_continent_code_by_name function which does exactly what I want except, of course, it's in PHP. Does anybody know of a JavaScript equivalent for this? It doesn't need to do any fancy address to latitude/longitude or similar things. It could be a standalone library, an NPM module, anything.

The PHP function uses the MaxMind databases. Maxmind also provide Node.js and Javascript libraries for their databases here

You can download the free MaxMind GeoLite database and install the node-maxmind package via npm. Here's an example of it in use (in coffeescipt, which you can also install via npm, or trivially translate to javascript):

maxmind = require('maxmind')
maxmind.init('GeoLiteCity.dat')
maxmind.getLocation('8.8.8.8').country # -> 'US'

If you'd rather not worry about having to keep your local GeoLite database up to date and your application can handle the additional latency of a web service call you can use a service like http://ipinfo.io. You can use the built in node.js http module to query it, or install request via npm to make things even easier:

request = require('request')
request.get('http://ipinfo.io', {json: true}, (e, r, details) ->
    console.log details.country # -> 'US'
)

Another advantage with http://ipinfo.io is that includes additional information, such as network owner and hostname.