as-callback.js 545 B

12345678910111213141516171819202122232425
  1. "use strict";
  2. module.exports = function (t, a) {
  3. if (typeof Promise !== "function") return null;
  4. return {
  5. Success: function (d) {
  6. t.call(new Promise(function (resolve) { resolve("foo"); }), function (error, value) {
  7. a(error, null);
  8. a(value, "foo");
  9. d();
  10. });
  11. },
  12. Failure: function (d) {
  13. var error = new Error("Rejection");
  14. t.call(new Promise(function (resolve, reject) { reject(error); }), function (
  15. passedError,
  16. value
  17. ) {
  18. a(passedError, error);
  19. a(value, undefined);
  20. d();
  21. });
  22. }
  23. };
  24. };