You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

51 lines
747 B

  1. /*!
  2. * Module dependencies.
  3. */
  4. var MPromise = require('./promise');
  5. /**
  6. * Helper for multiplexing promise implementations
  7. *
  8. * @api private
  9. */
  10. var Promise = {
  11. _promise: MPromise
  12. };
  13. /**
  14. * Get the current promise constructor
  15. *
  16. * @api private
  17. */
  18. Promise.get = function() {
  19. return Promise._promise;
  20. };
  21. /**
  22. * Set the current promise constructor
  23. *
  24. * @api private
  25. */
  26. Promise.set = function(lib) {
  27. if (lib === MPromise) {
  28. return Promise.reset();
  29. }
  30. Promise._promise = require('./ES6Promise');
  31. Promise._promise.use(lib);
  32. require('mquery').Promise = Promise._promise.ES6;
  33. };
  34. /**
  35. * Resets to using mpromise
  36. *
  37. * @api private
  38. */
  39. Promise.reset = function() {
  40. Promise._promise = MPromise;
  41. };
  42. module.exports = Promise;