MCPcopy
hub / github.com/ecyrbe/zodios / use

Method use

src/zodios.ts:190–214  ·  view source on GitHub ↗
(...args: unknown[])

Source from the content-addressed store, hash-verified

188 plugin: ZodiosPlugin
189 ): PluginId;
190 use(...args: unknown[]) {
191 if (typeof args[0] === "object") {
192 const plugins = this.getAnyEndpointPlugins()!;
193 return plugins.use(args[0] as ZodiosPlugin);
194 } else if (typeof args[0] === "string" && typeof args[1] === "object") {
195 const plugins = this.findAliasEndpointPlugins(args[0]);
196 if (!plugins)
197 throw new Error(
198 `Zodios: no alias '${args[0]}' found to register plugin`
199 );
200 return plugins.use(args[1] as ZodiosPlugin);
201 } else if (
202 typeof args[0] === "string" &&
203 typeof args[1] === "string" &&
204 typeof args[2] === "object"
205 ) {
206 const plugins = this.findEnpointPlugins(args[0] as Method, args[1]);
207 if (!plugins)
208 throw new Error(
209 `Zodios: no endpoint '${args[0]} ${args[1]}' found to register plugin`
210 );
211 return plugins.use(args[2] as ZodiosPlugin);
212 }
213 throw new Error("Zodios: invalid plugin registration");
214 }
215
216 /**
217 * unregister a plugin

Callers 4

constructorMethod · 0.95
api.test.tsFile · 0.45
zodios.test.tsFile · 0.45
example.tsFile · 0.45

Calls 3

getAnyEndpointPluginsMethod · 0.95
findEnpointPluginsMethod · 0.95

Tested by

no test coverage detected