-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.js
37 lines (30 loc) · 926 Bytes
/
index.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
'use strict'
const Scheduler = require('./lib/recurring').Scheduler
const EventEmitter = require('events')
function patchEmitter (emitter, newEmitter) {
const oldEmitter = emitter.emit
emitter.emit = function () {
newEmitter.emit.apply(newEmitter, arguments)
// send them through the websocket received as a parameter
oldEmitter.apply(emitter, arguments)
}
}
class Probe extends EventEmitter {
constructor () {
super()
this.schedule = new Scheduler()
patchEmitter(this.schedule, this)
}
add (config, expects) {
this.schedule.add(config, expects)
}
abort () {
this.schedule.abort()
}
}
module.exports = new Probe()
module.exports.Probe = Probe
module.exports.Ping = require('./lib/ping')
module.exports.Scheduler = require('./lib/recurring').Scheduler
module.exports.TimeRange = require('./lib/recurring').TimeRange
module.exports.HTTPRequest = require('./lib/request')