MCPcopy Create free account
hub / github.com/Effect-TS/effect / getUnderlyingSingleOrThrow

Function getUnderlyingSingleOrThrow

packages/effect/src/unstable/cli/Param.ts:2181–2197  ·  view source on GitHub ↗
(
  param: Param<Kind, A>
)

Source from the content-addressed store, hash-verified

2179 * @internal
2180 */
2181export const getUnderlyingSingleOrThrow = <Kind extends ParamKind, A>(
2182 param: Param<Kind, A>
2183): Single<Kind, A> => {
2184 const singles = extractSingleParams(param)
2185
2186 if (singles.length === 0) {
2187 throw new Error("No Single param found in param structure")
2188 }
2189
2190 if (singles.length > 1) {
2191 throw new Error(
2192 `Multiple Single params found: ${singles.map((s) => s.name).join(", ")}`
2193 )
2194 }
2195
2196 return singles[0] as Single<Kind, A>
2197}
2198
2199/**
2200 * Gets param metadata by traversing the structure.

Callers 3

Param.tsFile · 0.85
optionalFunction · 0.85
variadicFunction · 0.85

Calls 3

extractSingleParamsFunction · 0.85
joinMethod · 0.80
mapMethod · 0.45

Tested by

no test coverage detected