MCPcopy Index your code
hub / github.com/Effect-TS/effect / literal

Function literal

packages/effect/src/internal/config.ts:304–322  ·  view source on GitHub ↗
(...literals: Literals)

Source from the content-addressed store, hash-verified

302
303/** @internal */
304export const literal = <Literals extends ReadonlyArray<Config.LiteralValue>>(...literals: Literals) =>
305(
306 name?: string
307): Config.Config<Literals[number]> => {
308 const valuesString = literals.map(String).join(", ")
309 const config = primitive(`one of (${valuesString})`, (text) => {
310 const found = literals.find((value) => String(value) === text)
311 if (found === undefined) {
312 return Either.left(
313 configError.InvalidData(
314 [],
315 `Expected one of (${valuesString}) but received ${formatUnknown(text)}`
316 )
317 )
318 }
319 return Either.right(found)
320 })
321 return name === undefined ? config : nested(config, name)
322}
323
324/** @internal */
325export const logLevel = (name?: string): Config.Config<LogLevel.LogLevel> => {

Callers

nothing calls this directly

Calls 5

primitiveFunction · 0.85
StringInterface · 0.85
formatUnknownFunction · 0.85
joinMethod · 0.65
mapMethod · 0.65

Tested by

no test coverage detected