index.d.ts 1.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647
  1. // `AbortSignal`,`AbortController` are defined here to prevent a dependency on the `dom` library which disagrees with node runtime.
  2. // The definition for `AbortSignal` is taken from @types/node-fetch (https://github.com/DefinitelyTyped/DefinitelyTyped) for
  3. // maximal compatibility with node-fetch.
  4. // Original node-fetch definitions are under MIT License.
  5. export class AbortSignal {
  6. aborted: boolean;
  7. reason?: any;
  8. addEventListener: (
  9. type: "abort",
  10. listener: (this: AbortSignal, event: any) => any,
  11. options?:
  12. | boolean
  13. | {
  14. capture?: boolean;
  15. once?: boolean;
  16. passive?: boolean;
  17. }
  18. ) => void;
  19. removeEventListener: (
  20. type: "abort",
  21. listener: (this: AbortSignal, event: any) => any,
  22. options?:
  23. | boolean
  24. | {
  25. capture?: boolean;
  26. }
  27. ) => void;
  28. dispatchEvent: (event: any) => boolean;
  29. onabort: null | ((this: AbortSignal, event: any) => void);
  30. throwIfAborted(): void;
  31. static abort(reason?: any): AbortSignal;
  32. static timeout(time: number): AbortSignal;
  33. }
  34. export class AbortController {
  35. signal: AbortSignal;
  36. abort(reason?: any): void;
  37. }