index.js
function (err) {
      if (err) {
        callback(err, null)
      }
      _.each(ratesWithTimes, function (rates, currency) {
        rates.forEach(function (timeratepair) {
          var newEntry = {}
          newEntry[currency] = timeratepair.rate
          if (allRates[timeratepair.time]) {
            allRates[timeratepair.time].push(newEntry)
          } else {
            allRates[timeratepair.time] = [newEntry]
          }
        })
      })
      var allRatesNice = []
      _.each(allRates, function (rates, time) {
        var ratesNice = {}
        _.each(rates, function (currencyratepair) {
          _.each(currencyratepair, function (rate, currency) {
            ratesNice[currency] = rate
          })
        })
        allRatesNice.push({time: time, rates: ratesNice})
      })
      callback(null, allRatesNice)
    }
function (err) {
      if (err) {
        callback(err, null)
      }
      _.each(ratesWithTimes, function (rates, currency) {
        rates.forEach(function (timeratepair) {
          var newEntry = {}
          newEntry[currency] = timeratepair.rate
          if (allRates[timeratepair.time]) {
            allRates[timeratepair.time].push(newEntry)
          } else {
            allRates[timeratepair.time] = [newEntry]
          }
        })
      })
      var allRatesNice = []
      _.each(allRates, function (rates, time) {
        var ratesNice = {}
        _.each(rates, function (currencyratepair) {
          _.each(currencyratepair, function (rate, currency) {
            ratesNice[currency] = rate
          })
        })
        allRatesNice.push({time: time, rates: ratesNice})
      })
      callback(null, allRatesNice)
    }
function ( err ) { if ( err ) { callback ( err , null ) } _ . each ( ratesWithTimes , function ( rates , currency ) { rates . forEach ( function ( timeratepair ) { var newEntry = { } newEntry [ currency ] = timeratepair . rate if ( allRates [ timeratepair . time ] ) { allRates [ timeratepair . time ] . push ( newEntry ) } else { allRates [ timeratepair . time ] = [ newEntry ] } } ) } ) var allRatesNice = [ ] _ . each ( allRates , function ( rates , time ) { var ratesNice = { } _ . each ( rates , function ( currencyratepair ) { _ . each ( currencyratepair , function ( rate , currency ) { ratesNice [ currency ] = rate } ) } ) allRatesNice . push ( { time : time , rates : ratesNice } ) } ) callback ( null , allRatesNice ) }
3rd param is the function to call when everything's done
3rd param is the function to call when everything s done