waitFor.js 481 B

123456789101112131415161718192021222324252627
  1. var util = require('util')
  2. var events = require('events')
  3. var waitFor = function () {
  4. events.EventEmitter.call(this)
  5. }
  6. util.inherits(waitFor, events.EventEmitter)
  7. waitFor.prototype.command = function (ms, cb) {
  8. var self = this
  9. ms = ms || 1000
  10. setTimeout(function () {
  11. // if we have a callback, call it right before the complete event
  12. if (cb) {
  13. cb.call(self.client.api)
  14. }
  15. self.emit('complete')
  16. }, ms)
  17. return this
  18. }
  19. module.exports = waitFor