MCPcopy
hub / github.com/nodejs/undici / Cache

Class Cache

lib/web/cache/cache.js:27–807  ·  view source on GitHub ↗

* @see https://w3c.github.io/ServiceWorker/#dfn-request-response-list * @typedef {[any, any][]} requestResponseList

Source from the content-addressed store, hash-verified

25 */
26
27class Cache {
28 /**
29 * @see https://w3c.github.io/ServiceWorker/#dfn-relevant-request-response-list
30 * @type {requestResponseList}
31 */
32 #relevantRequestResponseList
33
34 constructor () {
35 if (arguments[0] !== kConstruct) {
36 webidl.illegalConstructor()
37 }
38
39 webidl.util.markAsUncloneable(this)
40 this.#relevantRequestResponseList = arguments[1]
41 }
42
43 async match (request, options = {}) {
44 webidl.brandCheck(this, Cache)
45
46 const prefix = 'Cache.match'
47 webidl.argumentLengthCheck(arguments, 1, prefix)
48
49 request = webidl.converters.RequestInfo(request)
50 options = webidl.converters.CacheQueryOptions(options, prefix, 'options')
51
52 const p = this.#internalMatchAll(request, options, 1)
53
54 if (p.length === 0) {
55 return
56 }
57
58 return p[0]
59 }
60
61 async matchAll (request = undefined, options = {}) {
62 webidl.brandCheck(this, Cache)
63
64 const prefix = 'Cache.matchAll'
65 if (request !== undefined) request = webidl.converters.RequestInfo(request)
66 options = webidl.converters.CacheQueryOptions(options, prefix, 'options')
67
68 return this.#internalMatchAll(request, options)
69 }
70
71 async add (request) {
72 webidl.brandCheck(this, Cache)
73
74 const prefix = 'Cache.add'
75 webidl.argumentLengthCheck(arguments, 1, prefix)
76
77 request = webidl.converters.RequestInfo(request)
78
79 // 1.
80 const requests = [request]
81
82 // 2.
83 const responseArrayPromise = this.addAll(requests)
84

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…