var urls = require('./urls') var request = require('request') function clean (data) { if('string' === typeof data) return data if(Array.isArray(data)) return data.map(clean) var o = {} for(var k in data) { if(!/^_/.test(k)) o[k] = clean(data[k]) } return o } var retrive = module.exports = function (name, cb) { var url = urls[name] console.error('GET', url) request({url: url, json: true}, function (err, response, json) { if(err) return cb(err) json.name = name cb(null, clean(json)) }) } if(!module.parent) { retrive(process.argv[2] || 'auckland', function (err, json) { if(err) throw err console.log(json) }) }