MCPcopy Create free account
hub / github.com/FlashpointProject/launcher / registerInterceptor

Function registerInterceptor

src/back/extensions/NodeInterceptor.ts:33–47  ·  view source on GitHub ↗
(interceptor: INodeModuleFactory, state: InterceptorState)

Source from the content-addressed store, hash-verified

31 * @param state State object holding all interceptor data
32 */
33export function registerInterceptor(interceptor: INodeModuleFactory, state: InterceptorState): void {
34 const { alternatives, factories } = state;
35 if (Array.isArray(interceptor.nodeModuleName)) {
36 for (const moduleName of interceptor.nodeModuleName) {
37 factories.set(moduleName, interceptor);
38 }
39 } else {
40 factories.set(interceptor.nodeModuleName, interceptor);
41 }
42 if (typeof interceptor.alternativeModuleName === 'function') {
43 alternatives.push((moduleName) => {
44 return interceptor.alternativeModuleName!(moduleName);
45 });
46 }
47}
48
49/**
50 * Installs the module interceptor. You can register interceptors even after this is called.

Callers 1

initializeFunction · 0.90

Calls 2

setMethod · 0.80
pushMethod · 0.65

Tested by

no test coverage detected