StorableRequest.d.ts 1.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263
  1. import '../_version.js';
  2. export interface RequestData {
  3. url: string;
  4. headers: {
  5. [headerName: string]: any;
  6. };
  7. body?: ArrayBuffer;
  8. [propName: string]: any;
  9. }
  10. /**
  11. * A class to make it easier to serialize and de-serialize requests so they
  12. * can be stored in IndexedDB.
  13. *
  14. * @private
  15. */
  16. declare class StorableRequest {
  17. private readonly _requestData;
  18. /**
  19. * Converts a Request object to a plain object that can be structured
  20. * cloned or JSON-stringified.
  21. *
  22. * @param {Request} request
  23. * @return {Promise<StorableRequest>}
  24. *
  25. * @private
  26. */
  27. static fromRequest(request: Request): Promise<StorableRequest>;
  28. /**
  29. * Accepts an object of request data that can be used to construct a
  30. * `Request` but can also be stored in IndexedDB.
  31. *
  32. * @param {Object} requestData An object of request data that includes the
  33. * `url` plus any relevant properties of
  34. * [requestInit]{@link https://fetch.spec.whatwg.org/#requestinit}.
  35. * @private
  36. */
  37. constructor(requestData: RequestData);
  38. /**
  39. * Returns a deep clone of the instances `_requestData` object.
  40. *
  41. * @return {Object}
  42. *
  43. * @private
  44. */
  45. toObject(): RequestData;
  46. /**
  47. * Converts this instance to a Request.
  48. *
  49. * @return {Request}
  50. *
  51. * @private
  52. */
  53. toRequest(): Request;
  54. /**
  55. * Creates and returns a deep clone of the instance.
  56. *
  57. * @return {StorableRequest}
  58. *
  59. * @private
  60. */
  61. clone(): StorableRequest;
  62. }
  63. export { StorableRequest };