function Prober()

in index.js [16:60]


function Prober(options) {
    if (!(this instanceof Prober)) {
        return new Prober(options);
    }

    options = options || {};

    this.title = options.title || defaults.title;
    this.threshold = options.threshold || defaults.threshold;
    this.window = options.window || defaults.window;
    this.now = options.now || Date.now;
    this.defaultWaitPeriod = options.defaultWaitPeriod ||
        defaults.defaultWaitPeriod;
    this.maxWaitPeriod = options.maxWaitPeriod || defaults.maxWaitPeriod;
    this.enabled = 'enabled' in options ? options.enabled : true;
    var detectFailuresBy = options.detectFailuresBy || Prober.detectBy.CALLBACK;
    this.detectFailuresByCallback =
        (detectFailuresBy === Prober.detectBy.CALLBACK) ||
        (detectFailuresBy === Prober.detectBy.BOTH);
    this.detectFailuresByEvent =
        (detectFailuresBy === Prober.detectBy.EVENT) ||
        (detectFailuresBy === Prober.detectBy.BOTH);

    this.logger = options.logger || null;
    this.bitRing = new BitRing(this.window);
    this.waitPeriod = this.defaultWaitPeriod;
    this.lastBackendRequest = this.now();
    this.statsd = options.statsd || null;

    this.isUnhealthyFunc = typeof options.isUnhealthyFunc === 'function' &&
        options.isUnhealthyFunc || defaults.isUnhealthyFunc;

    if (this.detectFailuresByEvent) {
        if (!options.backend) {
            if (this.logger) {
                this.logger.warn('Prober missing backend from' +
                    ' initialization options');
            }
            return;
        }

        options.backend.on(options.failureEvent, this.notok.bind(this));
        options.backend.on(options.successEvent, this.ok.bind(this));
    }
}