Sha256: f039f613d257d0ca8f35965a379a30ec504df5adf5ceb8c200be4fde292333c7

Contents?: true

Size: 709 Bytes

Versions: 26

Compression:

Stored size: 709 Bytes

Contents

import { FindWorker } from '../../glossary'

/**
 * Attempts to resolve a Service Worker instance from a given registration,
 * regardless of its state (active, installing, waiting).
 */
export function getWorkerByRegistration(
  registration: ServiceWorkerRegistration,
  absoluteWorkerUrl: string,
  findWorker: FindWorker,
): ServiceWorker | null {
  const allStates = [
    registration.active,
    registration.installing,
    registration.waiting,
  ]
  const relevantStates = allStates.filter((state): state is ServiceWorker => {
    return state != null
  })
  const worker = relevantStates.find((worker) => {
    return findWorker(worker.scriptURL, absoluteWorkerUrl)
  })

  return worker || null
}

Version data entries

26 entries across 26 versions & 1 rubygems

Version Path
clapton-0.0.26 lib/clapton/javascripts/node_modules/msw/src/browser/setupWorker/start/utils/getWorkerByRegistration.ts
clapton-0.0.25 lib/clapton/javascripts/node_modules/msw/src/browser/setupWorker/start/utils/getWorkerByRegistration.ts
clapton-0.0.24 lib/clapton/javascripts/node_modules/msw/src/browser/setupWorker/start/utils/getWorkerByRegistration.ts
clapton-0.0.23 lib/clapton/javascripts/node_modules/msw/src/browser/setupWorker/start/utils/getWorkerByRegistration.ts
clapton-0.0.22 lib/clapton/javascripts/node_modules/msw/src/browser/setupWorker/start/utils/getWorkerByRegistration.ts
clapton-0.0.21 lib/clapton/javascripts/node_modules/msw/src/browser/setupWorker/start/utils/getWorkerByRegistration.ts
clapton-0.0.20 lib/clapton/javascripts/node_modules/msw/src/browser/setupWorker/start/utils/getWorkerByRegistration.ts
clapton-0.0.19 lib/clapton/javascripts/node_modules/msw/src/browser/setupWorker/start/utils/getWorkerByRegistration.ts
clapton-0.0.18 lib/clapton/javascripts/node_modules/msw/src/browser/setupWorker/start/utils/getWorkerByRegistration.ts
clapton-0.0.17 lib/clapton/javascripts/node_modules/msw/src/browser/setupWorker/start/utils/getWorkerByRegistration.ts
clapton-0.0.16 lib/clapton/javascripts/node_modules/msw/src/browser/setupWorker/start/utils/getWorkerByRegistration.ts
clapton-0.0.15 lib/clapton/javascripts/node_modules/msw/src/browser/setupWorker/start/utils/getWorkerByRegistration.ts
clapton-0.0.14 lib/clapton/javascripts/node_modules/msw/src/browser/setupWorker/start/utils/getWorkerByRegistration.ts
clapton-0.0.13 lib/clapton/javascripts/node_modules/msw/src/browser/setupWorker/start/utils/getWorkerByRegistration.ts
clapton-0.0.12 lib/clapton/javascripts/node_modules/msw/src/browser/setupWorker/start/utils/getWorkerByRegistration.ts
clapton-0.0.11 lib/clapton/javascripts/node_modules/msw/src/browser/setupWorker/start/utils/getWorkerByRegistration.ts
clapton-0.0.10 lib/clapton/javascripts/node_modules/msw/src/browser/setupWorker/start/utils/getWorkerByRegistration.ts
clapton-0.0.9 lib/clapton/javascripts/node_modules/msw/src/browser/setupWorker/start/utils/getWorkerByRegistration.ts
clapton-0.0.8 lib/clapton/javascripts/node_modules/msw/src/browser/setupWorker/start/utils/getWorkerByRegistration.ts
clapton-0.0.7 lib/clapton/javascripts/node_modules/msw/src/browser/setupWorker/start/utils/getWorkerByRegistration.ts