AbortController.js 1.2 KB

1234567891011121314151617181920212223242526272829303132333435363738
  1. // Copyright (c) .NET Foundation. All rights reserved.
  2. // Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
  3. // Rough polyfill of https://developer.mozilla.org/en-US/docs/Web/API/AbortController
  4. // We don't actually ever use the API being polyfilled, we always use the polyfill because
  5. // it's a very new API right now.
  6. // Not exported from index.
  7. /** @private */
  8. var AbortController = /** @class */ (function () {
  9. function AbortController() {
  10. this.isAborted = false;
  11. this.onabort = null;
  12. }
  13. AbortController.prototype.abort = function () {
  14. if (!this.isAborted) {
  15. this.isAborted = true;
  16. if (this.onabort) {
  17. this.onabort();
  18. }
  19. }
  20. };
  21. Object.defineProperty(AbortController.prototype, "signal", {
  22. get: function () {
  23. return this;
  24. },
  25. enumerable: true,
  26. configurable: true
  27. });
  28. Object.defineProperty(AbortController.prototype, "aborted", {
  29. get: function () {
  30. return this.isAborted;
  31. },
  32. enumerable: true,
  33. configurable: true
  34. });
  35. return AbortController;
  36. }());
  37. export { AbortController };
  38. //# sourceMappingURL=AbortController.js.map