timeout.js 639 B

123456789101112131415161718192021222324252627
  1. /** @license MIT License (c) copyright 2011-2013 original author or authors */
  2. /**
  3. * timeout.js
  4. *
  5. * Helper that returns a promise that rejects after a specified timeout,
  6. * if not explicitly resolved or rejected before that.
  7. *
  8. * @author Brian Cavalier
  9. * @author John Hann
  10. */
  11. (function(define) {
  12. define(function(require) {
  13. var when = require('./when');
  14. /**
  15. * @deprecated Use when(trigger).timeout(ms)
  16. */
  17. return function timeout(msec, trigger) {
  18. return when(trigger).timeout(msec);
  19. };
  20. });
  21. })(typeof define === 'function' && define.amd ? define : function (factory) { module.exports = factory(require); });