AbortController.js 836 B

12345678910111213141516171819202122232425262728
  1. // Licensed to the .NET Foundation under one or more agreements.
  2. // The .NET Foundation licenses this file to you under the MIT license.
  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. export class AbortController {
  9. constructor() {
  10. this._isAborted = false;
  11. this.onabort = null;
  12. }
  13. abort() {
  14. if (!this._isAborted) {
  15. this._isAborted = true;
  16. if (this.onabort) {
  17. this.onabort();
  18. }
  19. }
  20. }
  21. get signal() {
  22. return this;
  23. }
  24. get aborted() {
  25. return this._isAborted;
  26. }
  27. }
  28. //# sourceMappingURL=AbortController.js.map