MCPcopy
hub / github.com/mswjs/msw / constructor

Method constructor

src/browser/sources/service-worker-source.ts:84–98  ·  view source on GitHub ↗
(options: ServiceWorkerSourceOptions)

Source from the content-addressed store, hash-verified

82 >
83
84 constructor(options: ServiceWorkerSourceOptions) {
85 super()
86
87 invariant(
88 supportsServiceWorker(),
89 'Failed to use Service Worker as the network source: the Service Worker API is not supported in this environment',
90 )
91
92 this.#options = options
93 this.#frames = new Map()
94 this.workerPromise = new DeferredPromise()
95 this.#channel = new WorkerChannel({
96 getWorker: () => this.workerPromise.then(([worker]) => worker),
97 })
98 }
99
100 public async enable(): Promise<ServiceWorkerRegistration> {
101 /**

Callers

nothing calls this directly

Calls 2

supportsServiceWorkerFunction · 0.90
invariantFunction · 0.85

Tested by

no test coverage detected