AbortController.js 1.3 KB

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