Build up a string based on the astroViewer data
@param  {object}   data Return the astroviewer object
@param  {Function} cb
510791
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)
}
838564
function(arr, cb){
			for(var i =0, len = arr.length; i <len; i++){
				cb.call(arr[i],i,arr[i])
			}
			return arr;
		}
221986
function (self, cmd, channel, data, cb) {
		if (typeof(cb) != "function") {
			cb = false;
		}

		if (typeof(channel) == "number") {
			channel = channel.toString();
		}

		if (typeof(channel) != "string" || !/[0-9]+-[0-9]+/.test(channel)) {
			self.log("Invalid channel");
			return cb && cb(new Error("Invalid channel"));
		}

		if (typeof(data) != "string") {
			data = self.datObJectToXml(data);
		}

		if (typeof(data) != "string") {
			self.log("Invalid data");
			return cb && cb(new Error("Invalid data"));
		}

		self.sendCommand("CG " + channel + " " + cmd + " 1 \"" + data + "\"", cb);
	}
1189003
function(element, dataId, cb) {
    localforage.getItem(dataId, function localforageGetItemCallback(err, data) {
      $myelements.debug("Trying to get localstorage data for scope: %s", dataId);
      if (err) {
        return cb(err, data);
      }
      if (!data) {
        $myelements.debug("No localstorage for scope: %s", dataId);
        return cb(new Error("No localstorage data for DataId " + dataId));
      } else {
        $myelements.debug("Got localstorage for scope: %s", dataId);
        return cb(null, data);
      }
    });
  }
875330
function load(opts, cb) {
  if(typeof opts === 'function') {
    cb = opts;
    opts = undefined;
  }

  if(typeof opts === 'string') {
    file = opts;
  }else if(typeof opts === 'object') {
    file = opts.file;
  }

  if(file === undefined) file = DEFAULT_FILE;

  var sync = typeof cb !== 'function'
    , stream
    , file
    , reader
    , decoder = new Decoder(this, this.options, file);

  if(!file || typeof file !== 'string' && !(file instanceof Readable)){
    return this.emit('error',
      new Error('cannot load configuration, path or stream expected'));
  }

  // need absolute path to be able to
  // correctly find circular references
  if(typeof file === 'string') {
    file = resolve(file);
  }

  this._file = file;

  if(sync && file && typeof file === 'string') {
    this._lines = (fs.readFileSync(file) + '').split(this.options.eol);
    decoder.parse(this._lines);
    if(opts && opts.directives) {
      this.directives(opts.directives);
    }
    return decoder;
  }

  if(file instanceof Readable) {
    stream = file;
  }else{
    /* istanbul ignore next: cannot mock stdin, readable only */
    stream = opts && opts.stdin ? process.stdin
      : fs.createReadStream(file, this.options.read)
  }

  reader = new LineReader(this.options);

  this.once('load', cb);

  function onEnd() {

    if(opts && opts.directives) {
      this.directives(opts.directives);
    }

    decoder.removeAllListeners('error');
    reader.removeAllListeners('error');
    stream.removeAllListeners('error');

    //console.dir(opts);
    //
    this.onLoad();

    this.emit('load', this);
  }

  function onLines(lines) {
    this._lines = this._lines.concat(lines);
  }

  var onError = this.onError.bind(this);
  decoder.on('error', onError);
  stream.on('error', onError);
  reader.on('error', onError);

  // listen for includes
  this.on('include', this.onInclude.bind(this))

  // listen for lines on the primary configuration.
  decoder.on('lines', onLines.bind(this));

  stream.on('end', onEnd.bind(this));
  stream.pipe(reader).pipe(decoder);
  return reader;
}
286816
function (o, cb) {
    if (!o.src) {
      throw new Error('glob missing');
    }
    if (!o.out) {
      throw new Error('output dir missing');
    }

    var opts = _.extend({}, defaults, o);
    if (opts.style && path.basename(opts.style).indexOf('.') === -1) {
      opts.style = path.join(opts.style, replaceExtension(opts.name, '.' + opts.processor));
    }
    vfs.src(opts.src)
      .pipe(sprite(opts))
      .pipe(through2.obj(writeFile))
      .on('data', noop)
      .on('end', function () {
        if (_.isFunction(cb)) {
          cb();
        }
      });
  }
70838
function createJSScript(id, src, cb) {
  var headElement = document.getElementsByTagName("head")[0];

  var scripter = document.createElement('script');
  scripter.setAttribute("type", 'text/javascript');
  scripter.setAttribute("id", id);
  if (src.indexOf('http') === 0 || src.indexOf('/') === 0) {
    scripter.onload = scripter.onreadystatechange = function () {
      if (!this.readyState || this.readyState == 'loaded' || this.readyState == 'complete') {
        ImmitSax.data[id] = 'finish'
        setTimeout(function(){
          ImmitSax.roll(id)
          ImmitSax.off(id)
        }, 200);
      }
    }
    // if (src.lastIndexOf('.js')==-1) src += '.js'
    scripter.setAttribute("src", src);
    headElement.appendChild(scripter);
  }
  else {
    scripter.appendChild(document.createTextNode(src))
    headElement.appendChild(scripter);
    ImmitSax.data[id] = 'finish'
    ImmitSax.roll(id)
    ImmitSax.off(id)
  }
}
887404
function process(data) {
  var result = '';
  for(var cChar = 0; cChar < data.length; cChar += 2) {
    result += String.fromCharCode(parseInt(data.substr(cChar,2),16));
  }
  return result;
}
604498
function(bs, data) {
        const type = data.type;
        if (bs.options.get('json')) {
            return console.log(JSON.stringify({
                "service:running": {
                    "options": bs.options.toJS()
                }
            }));
        }
        if (type === "server") {
            var baseDir = bs.options.getIn(["server", "baseDir"]);

            logUrls(bs.options.get("urls").toJS());

            if (baseDir) {
                if (utils.isList(baseDir)) {
                    baseDir.forEach(serveFiles);
                } else {
                    serveFiles(baseDir);
                }
            }
        }

        if (type === "proxy") {
            logger.info(
                "Proxying: {cyan:%s}",
                bs.options.getIn(["proxy", "target"])
            );
            logUrls(bs.options.get("urls").toJS());
        }

        if (type === "snippet") {
            if (bs.options.get("logSnippet")) {
                logger.info(
                    "{bold:Copy the following snippet into your website, " +
                        "just before the closing {cyan:</body>} tag"
                );

                logger.unprefixed("info", messages.scriptTags(bs.options));
            }

            logUrls(
                bs.options
                    .get("urls")
                    .filter(function(value, key) {
                        return key.slice(0, 2) === "ui";
                    })
                    .toJS()
            );
        }

        function serveFiles(base) {
            logger.info("Serving files from: {magenta:%s}", base);
        }
    }
1201493
function writeblobs(data, cb) {
    var ab = asyncbuilder(cb);
    var reqQ = new Queue( { concurrency: 5 } );

    u.each(data, function(file) {
      var append = ab.asyncAppend();
      var blob = { encoding: file.buffer ? 'base64' : 'utf-8',
                   content: file.buffer ? file.buffer.toString('base64') : (file.text || '') };

      reqQ.push(function(reqDone) {
        post(self.endpoint + '/git/blobs', blob, function(err, ghblob) {
          if (ghblob) { file.sha = ghblob.sha; }
          append(err, file);
          reqDone();
        });
      });

    });
    ab.complete();
  }
1350220
function (cb) {
            var self = this;
            var dirs = ['classes', 'modules', 'files'];
            if (self.options.dumpview) {
                dirs.push('json');
            }
            var writeRedirect = function (dir, file, cb) {
                Y.Files.exists(file, function (x) {
                    if (x) {
                        var out = path.join(dir, 'index.html');
                        fs.createReadStream(file).pipe(fs.createWriteStream(out));
                    }
                    cb();
                });
            };
            var defaultIndex = path.join(themeDir, 'assets', 'index.html');
            var stack = new Y.Parallel();
            Y.log('Making default directories: ' + dirs.join(','), 'info', 'builder');
            dirs.forEach(function (d) {
                var dir = path.join(self.options.outdir, d);
                Y.Files.exists(dir, stack.add(function (x) {
                    if (!x) {
                        fs.mkdir(dir, 0777, stack.add(function () {
                            writeRedirect(dir, defaultIndex, stack.add(noop));
                        }));
                    } else {
                        writeRedirect(dir, defaultIndex, stack.add(noop));
                    }
                }));
            });
            stack.done(function () {
                if (cb) {
                    cb();
                }
            });
        }
1045430
function (_data, cb) {
      if(!db.data) return cb(new Error('kiddb not open'))
      if(!writing) return db._update(_data, cb)
      db.__data = _data
      qcb.push(cb)
      onWrote = function () {
        onWrote = null
        var cbs = qcb; qcb = []
        var _data = db.__data
        db.__data = null
        db.update(_data, function (err) {
          cbs.forEach(function (cb) {
            cb(err)
          })
        })
      }
    }
45525
function dataToObjects (data) {
  if (!data) return null
  if (data instanceof Array) {
    return data.map(function(doc) { 
      return doc.toObject()
    })
  }
  return data.toObject()
}
1290205
function(data){
			this.segments = [];
			//Declare segment class as a chart instance specific class, so it can share props for this instance
			this.SegmentArc = Chart.Arc.extend({
				showStroke : this.options.segmentShowStroke,
				strokeWidth : this.options.segmentStrokeWidth,
				strokeColor : this.options.segmentStrokeColor,
				ctx : this.chart.ctx,
				innerRadius : 0,
				x : this.chart.width/2,
				y : this.chart.height/2
			});
			this.scale = new Chart.RadialScale({
				display: this.options.showScale,
				fontStyle: this.options.scaleFontStyle,
				fontSize: this.options.scaleFontSize,
				fontFamily: this.options.scaleFontFamily,
				fontColor: this.options.scaleFontColor,
				showLabels: this.options.scaleShowLabels,
				showLabelBackdrop: this.options.scaleShowLabelBackdrop,
				backdropColor: this.options.scaleBackdropColor,
				backdropPaddingY : this.options.scaleBackdropPaddingY,
				backdropPaddingX: this.options.scaleBackdropPaddingX,
				lineWidth: (this.options.scaleShowLine) ? this.options.scaleLineWidth : 0,
				lineColor: this.options.scaleLineColor,
				lineArc: true,
				width: this.chart.width,
				height: this.chart.height,
				xCenter: this.chart.width/2,
				yCenter: this.chart.height/2,
				ctx : this.chart.ctx,
				templateString: this.options.scaleLabel,
				valuesCount: data.length
			});

			this.updateScaleRange(data);

			this.scale.update();

			helpers.each(data,function(segment,index){
				this.addData(segment,index,true);
			},this);

			//Set up tooltip events on the chart
			if (this.options.showTooltips){
				helpers.bindEvents(this, this.options.tooltipEvents, function(evt){
					var activeSegments = (evt.type !== 'mouseout') ? this.getSegmentsAtEvent(evt) : [];
					helpers.each(this.segments,function(segment){
						segment.restore(["fillColor"]);
					});
					helpers.each(activeSegments,function(activeSegment){
						activeSegment.fillColor = activeSegment.highlightColor;
					});
					this.showTooltip(activeSegments);
				});
			}

			this.render();
		}
840737
function(callback) {
			var self = this;
			var userService = this.serviceRegistry.getService("orion.core.user"); 
			var authServices = this.serviceRegistry.getServiceReferences("orion.core.auth");
			var authService = this.serviceRegistry.getService(authServices[0]);
			authService.getUser().then(function(jsonData) {
				userService.getUserInfo(contextPath + jsonData.Location).then(function(accountData) {
					var username = accountData.UserName;
					self.clientDisplayedName = accountData.FullName || username;
					var MASK = 0xFFFFFF + 1;
					var MAGIC = 161803398 / 2 % MASK;
					self.clientId = username + '.' + guid.substr(0, 4);
					callback();
				}, function(err) {
					console.error(err);
				});
			});
		}
434514
function(key, cb, reader) {
        var decrypt, finished, gunzip, jsParse;
        if (!devices) {
          if (typeof cb === "function") {
            cb('no devices', null);
          }
          return typeof done === "function" ? done() : void 0;
        } else {
          jsParse = new jsonStream.parse('*');
          decrypt = crypto.createDecipher(algorithm, settings.ENCRYPTION_KEY || settings.SESSION_SECRET || '5random7493nonsens!e');
          gunzip = zlib.createGunzip();
          finished = false;
          return async.eachSeries(devices, function(device, callback) {
            var calledBack, st;
            if (!finished) {
              calledBack = false;
              if (!reader) {
                reader = device.getReadStream(key);
              }
              st = reader;
              if (doencrypt) {
                st = st.pipe(decrypt);
              }
              if (dozip) {
                st = st.pipe(gunzip);
              }
              st.pipe(jsParse).pipe(es.mapSync(function(data) {
                finished = true;
                calledBack = true;
                if (typeof cb === "function") {
                  cb(null, data);
                }
                if (typeof done === "function") {
                  done();
                }
                return callback();
              }));
              reader.on('error', function(e) {
                if (!calledBack) {
                  calledBack = true;
                  return callback();
                }
              });
              st.on('error', function(e) {
                if (!calledBack) {
                  calledBack = true;
                  finished = true;
                  if (typeof cb === "function") {
                    cb('encrypt error', null);
                  }
                  return callback();
                }
              });
              jsParse.on('error', function(e) {
                return console.log('Error parsing database - have you changed your encryption key or turned encryption on or off?  If so, update your database using ndx-framework.');
              });
              return st.on('end', function() {
                if (!calledBack) {
                  calledBack = true;
                  return callback();
                }
              });
            } else {
              return callback();
            }
          }, function() {
            if (!finished) {
              if (typeof cb === "function") {
                cb('nothing found', null);
              }
              return typeof done === "function" ? done() : void 0;
            }
          });
        }
      }
733939
function init(config, cb) {
    connection = mongoose.createConnection(config.mongoUrl);

    var firstCallback = true;

    connection.on('error', function(err) {
      log.logger.error('Mongo error: ' + util.inspect(err));
      if (firstCallback) {
        firstCallback = false;
        return cb(err);
      } else {
        log.logger.error('Mongo error: ' + util.inspect(err));
        return cb(err);
      }
    });

    connection.once('open', function callback() {
      if (firstCallback) {
        log.logger.debug('Mongoose connected.');
        firstCallback = false;
        return cb(null,connection);
      }
      else {
        return cb();
      }
    });

    connection.on('disconnected', function() {
      log.logger.debug('Mongoose event - disconnect');
    });
    
    // Load schemas
    models.Mbaas = connection.model('Mbaas', require('./models/mbaas.js'));
    models.AppMbaas = connection.model('AppMbaas', require('./models/appMbaas.js'));
    models.Event = connection.model('Events', require('./models/events.js').EventSchema);
    models.Alert = connection.model('Alerts', require('./models/alerts.js').AlertSchema);
    models.Notification = connection.model("Notification",require('./models/notifications').NotificationSchema);
    models.Crash = connection.model("Crash",require('./models/crash').CrashSchema);
}