event-within
v0.0.0
Published
register event handlers for a certain time frame
Downloads
4
Readme
event-within
Register event handlers for a certain time frame.
Get it!
npm install --save event-within
Usage
node usage
and type sth:
var withinify = require('event-within')
var stdwithin = withinify(process.stdin)
stdwithin.onwithin('data', Date.now() + 15000, function (chunk) {
console.log('within::', chunk.toString())
})
API
emitter = withinify(emitter)
Add two custom event registration functions on your emitter.
emitter.onwithin(event[, start], end, handler)
Register an event handler for a certain time. start
and end
must be timestamps. start
is optional and defaults to Date.now()
.
emitter.oncewithin(event[, start], end, handler)
Register an one-time event handler for a certain time. start
and end
must be timestamps. start
is optional and defaults to Date.now()
.