lib/ping.js
function Ping(url, driver) {
  if (!(this instanceof Ping)) {
    return new Ping(url, driver);
  }

  driver = driver || request;

  this.url = url;
  this.driver = driver;
  this.successCodes = SUCCESS;
  this.started = false;
  this.validators = [];
  var self = this;

  var textCheck = function(err, res, body) {
    if (!self._text) return true;
    return ~body.indexOf(self._text);
  };

  var errorCheck = function(err, res) {
    return !err;
  };

  var statusCheck = function(err, res, body) {
    // If there is no result from the server, assume site is down.
    if (!res){
      return false;
    } else {
      return ~self.successCodes.indexOf(res.statusCode);
    }
  };

  var perfCheck = function(err, res, body, info) {
    if (typeof self._maxDuration !== 'number') return true;
    return info.duration <= self._maxDuration;
  };

  this.register(errorCheck, statusCheck, textCheck, perfCheck);
}
function Ping(url, driver) {
  if (!(this instanceof Ping)) {
    return new Ping(url, driver);
  }

  driver = driver || request;

  this.url = url;
  this.driver = driver;
  this.successCodes = SUCCESS;
  this.started = false;
  this.validators = [];
  var self = this;

  var textCheck = function(err, res, body) {
    if (!self._text) return true;
    return ~body.indexOf(self._text);
  };

  var errorCheck = function(err, res) {
    return !err;
  };

  var statusCheck = function(err, res, body) {
    // If there is no result from the server, assume site is down.
    if (!res){
      return false;
    } else {
      return ~self.successCodes.indexOf(res.statusCode);
    }
  };

  var perfCheck = function(err, res, body, info) {
    if (typeof self._maxDuration !== 'number') return true;
    return info.duration <= self._maxDuration;
  };

  this.register(errorCheck, statusCheck, textCheck, perfCheck);
}
function Ping ( url , driver ) { if ( ! ( this instanceof Ping ) ) { return new Ping ( url , driver ) ; } driver = driver || request ; this . url = url ; this . driver = driver ; this . successCodes = SUCCESS ; this . started = false ; this . validators = [ ] ; var self = this ; var textCheck = function ( err , res , body ) { if ( ! self . _text ) return true ; return ~ body . indexOf ( self . _text ) ; } ; var errorCheck = function ( err , res ) { return ! err ; } ; var statusCheck = function ( err , res , body ) { // If there is no result from the server, assume site is down. if ( ! res ) { return false ; } else { return ~ self . successCodes . indexOf ( res . statusCode ) ; } } ; var perfCheck = function ( err , res , body , info ) { if ( typeof self . _maxDuration !== 'number' ) return true ; return info . duration <= self . _maxDuration ; } ; this . register ( errorCheck , statusCheck , textCheck , perfCheck ) ; }
Ping class.

@param {String} url
@param {Object} driver
@constructor
Ping class .