Sha256: a8589c3c04a8ed5464b3db54921f373445946f5787f6e6ca77670fe21804c784
Contents?: true
Size: 1.13 KB
Versions: 26
Compression:
Stored size: 1.13 KB
Contents
import { RequiredDeep } from '~/core/typeUtils' import { mergeRight } from '~/core/utils/internal/mergeRight' import { SetupWorker, SetupWorkerInternalContext, StartHandler, StartOptions, } from '../../glossary' export const DEFAULT_START_OPTIONS: RequiredDeep<StartOptions> = { serviceWorker: { url: '/mockServiceWorker.js', options: null as any, }, quiet: false, waitUntilReady: true, onUnhandledRequest: 'warn', findWorker(scriptURL, mockServiceWorkerUrl) { return scriptURL === mockServiceWorkerUrl }, } /** * Returns resolved worker start options, merging the default options * with the given custom options. */ export function resolveStartOptions( initialOptions?: StartOptions, ): RequiredDeep<StartOptions> { return mergeRight( DEFAULT_START_OPTIONS, initialOptions || {}, ) as RequiredDeep<StartOptions> } export function prepareStartHandler( handler: StartHandler, context: SetupWorkerInternalContext, ): SetupWorker['start'] { return (initialOptions) => { context.startOptions = resolveStartOptions(initialOptions) return handler(context.startOptions, initialOptions || {}) } }
Version data entries
26 entries across 26 versions & 1 rubygems