MCPcopy
hub / github.com/crxjs/chrome-extension-tools / narrowEvent

Function narrowEvent

src/xstate_helpers.ts:25–39  ·  view source on GitHub ↗
(
  event: TEvent,
  types: string | string[],
)

Source from the content-addressed store, hash-verified

23 type: TEventType[],
24): ExtractEvent<TEvent, TEventType>
25export function narrowEvent<TEvent extends EventObject>(
26 event: TEvent,
27 types: string | string[],
28): EventObject {
29 types = Array.isArray(types) ? types : [types]
30 if (!types.includes(event.type)) {
31 throw new Error(
32 `Expected event${
33 types.length > 1 ? 's' : ''
34 } "${types.join(', ')}" but got "${event.type}".`,
35 )
36 }
37
38 return event
39}
40
41export interface UseMachineOptions<
42 TContext,

Callers 10

setupPluginsRunnerFunction · 0.90
setupFileEmitterFunction · 0.90
generateBundleFunction · 0.90
files.machine.tsFile · 0.90
handleBundleStartFunction · 0.90
handleBundleEndFunction · 0.90
handleErrorFunction · 0.90
handleFatalErrorFunction · 0.90

Calls

no outgoing calls

Tested by

no test coverage detected