0.0.0 • Published 6 years ago

event-within v0.0.0

Weekly downloads
1
License
MIT
Repository
github
Last release
6 years ago

event-within

build status AppVeyor Build Status


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().


License

MIT