src/index.js
function listPasses (data, cb) {
  var index = 0
  var passes = data.passes
  var newpasses = ''
  if (passes.length === 0) {
    newpasses += ':( No results found for **' + data.location.name + '**'
  } else {
    passes.map(function (obj) {
      if (index === 0) {
        newpasses += '**' + data.location.name + '** (' + obj.timezone + ')\n'
      }
      var dateFormat = 'YYYYMMDDHHmmss'
      var newDateFormat = 'ddd MMM Do, hh:mma'
      var begin = moment(obj.begin, dateFormat).format(newDateFormat)
      var duration = moment.utc(moment(obj.end, dateFormat).diff(moment(obj.begin, dateFormat))).format('m\\m s\\s')
      newpasses += begin + ' (' + duration + ')\n'
      index++
    })
  }
  newpasses += ':satellite:'
  cb(false, newpasses)
}
function listPasses (data, cb) {
  var index = 0
  var passes = data.passes
  var newpasses = ''
  if (passes.length === 0) {
    newpasses += ':( No results found for **' + data.location.name + '**'
  } else {
    passes.map(function (obj) {
      if (index === 0) {
        newpasses += '**' + data.location.name + '** (' + obj.timezone + ')\n'
      }
      var dateFormat = 'YYYYMMDDHHmmss'
      var newDateFormat = 'ddd MMM Do, hh:mma'
      var begin = moment(obj.begin, dateFormat).format(newDateFormat)
      var duration = moment.utc(moment(obj.end, dateFormat).diff(moment(obj.begin, dateFormat))).format('m\\m s\\s')
      newpasses += begin + ' (' + duration + ')\n'
      index++
    })
  }
  newpasses += ':satellite:'
  cb(false, newpasses)
}
function listPasses ( data , cb ) { var index = 0 var passes = data . passes var newpasses = '' if ( passes . length === 0 ) { newpasses += ':( No results found for **' + data . location . name + '**' } else { passes . map ( function ( obj ) { if ( index === 0 ) { newpasses += '**' + data . location . name + '** (' + obj . timezone + ')\n' } var dateFormat = 'YYYYMMDDHHmmss' var newDateFormat = 'ddd MMM Do, hh:mma' var begin = moment ( obj . begin , dateFormat ) . format ( newDateFormat ) var duration = moment . utc ( moment ( obj . end , dateFormat ) . diff ( moment ( obj . begin , dateFormat ) ) ) . format ( 'm\\m s\\s' ) newpasses += begin + ' (' + duration + ')\n' index ++ } ) } newpasses += ':satellite:' cb ( false , newpasses ) }
Build up a string based on the astroViewer data
@param  {object}   data Return the astroviewer object
@param  {Function} cb
Build up a string based on the astroViewer data