cache.d.ts 1.2 KB

123456789101112131415161718192021222324252627282930313233343536
  1. import type { RequestInfo, Response, Request } from './fetch'
  2. export interface CacheStorage {
  3. match (request: RequestInfo, options?: MultiCacheQueryOptions): Promise<Response | undefined>,
  4. has (cacheName: string): Promise<boolean>,
  5. open (cacheName: string): Promise<Cache>,
  6. delete (cacheName: string): Promise<boolean>,
  7. keys (): Promise<string[]>
  8. }
  9. declare const CacheStorage: {
  10. prototype: CacheStorage
  11. new(): CacheStorage
  12. }
  13. export interface Cache {
  14. match (request: RequestInfo, options?: CacheQueryOptions): Promise<Response | undefined>,
  15. matchAll (request?: RequestInfo, options?: CacheQueryOptions): Promise<readonly Response[]>,
  16. add (request: RequestInfo): Promise<undefined>,
  17. addAll (requests: RequestInfo[]): Promise<undefined>,
  18. put (request: RequestInfo, response: Response): Promise<undefined>,
  19. delete (request: RequestInfo, options?: CacheQueryOptions): Promise<boolean>,
  20. keys (request?: RequestInfo, options?: CacheQueryOptions): Promise<readonly Request[]>
  21. }
  22. export interface CacheQueryOptions {
  23. ignoreSearch?: boolean,
  24. ignoreMethod?: boolean,
  25. ignoreVary?: boolean
  26. }
  27. export interface MultiCacheQueryOptions extends CacheQueryOptions {
  28. cacheName?: string
  29. }
  30. export declare const caches: CacheStorage