abort-controller.d.ts 1020 B

12345678910111213141516171819202122232425262728293031323334353637383940414243
  1. import { EventTarget } from "event-target-shim"
  2. type Events = {
  3. abort: any
  4. }
  5. type EventAttributes = {
  6. onabort: any
  7. }
  8. /**
  9. * The signal class.
  10. * @see https://dom.spec.whatwg.org/#abortsignal
  11. */
  12. declare class AbortSignal extends EventTarget<Events, EventAttributes> {
  13. /**
  14. * AbortSignal cannot be constructed directly.
  15. */
  16. constructor()
  17. /**
  18. * Returns `true` if this `AbortSignal`"s `AbortController` has signaled to abort, and `false` otherwise.
  19. */
  20. readonly aborted: boolean
  21. }
  22. /**
  23. * The AbortController.
  24. * @see https://dom.spec.whatwg.org/#abortcontroller
  25. */
  26. declare class AbortController {
  27. /**
  28. * Initialize this controller.
  29. */
  30. constructor()
  31. /**
  32. * Returns the `AbortSignal` object associated with this object.
  33. */
  34. readonly signal: AbortSignal
  35. /**
  36. * Abort and signal to any observers that the associated activity is to be aborted.
  37. */
  38. abort(): void
  39. }
  40. export default AbortController
  41. export { AbortController, AbortSignal }