index.d.ts 1.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041
  1. export declare type ConnectionInfo = {
  2. url: string;
  3. headers?: {
  4. [key: string]: string | number;
  5. };
  6. user?: string;
  7. password?: string;
  8. allowInsecureAuthentication?: boolean;
  9. allowGzip?: boolean;
  10. throttleLimit?: number;
  11. throttleSlotInterval?: number;
  12. throttleCallback?: (attempt: number, url: string) => Promise<boolean>;
  13. skipFetchSetup?: boolean;
  14. errorPassThrough?: boolean;
  15. timeout?: number;
  16. };
  17. export interface OnceBlockable {
  18. once(eventName: "block", handler: () => void): void;
  19. }
  20. export interface OncePollable {
  21. once(eventName: "poll", handler: () => void): void;
  22. }
  23. export declare type PollOptions = {
  24. timeout?: number;
  25. floor?: number;
  26. ceiling?: number;
  27. interval?: number;
  28. retryLimit?: number;
  29. onceBlock?: OnceBlockable;
  30. oncePoll?: OncePollable;
  31. };
  32. export declare type FetchJsonResponse = {
  33. statusCode: number;
  34. headers: {
  35. [header: string]: string;
  36. };
  37. };
  38. export declare function _fetchData<T = Uint8Array>(connection: string | ConnectionInfo, body?: Uint8Array, processFunc?: (value: Uint8Array, response: FetchJsonResponse) => T): Promise<T>;
  39. export declare function fetchJson(connection: string | ConnectionInfo, json?: string, processFunc?: (value: any, response: FetchJsonResponse) => any): Promise<any>;
  40. export declare function poll<T>(func: () => Promise<T>, options?: PollOptions): Promise<T>;
  41. //# sourceMappingURL=index.d.ts.map