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

Function literal

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

Source from the content-addressed store, hash-verified

311
312/** @internal */
313export const literal = <Literals extends ReadonlyArray<Config.LiteralValue>>(...literals: Literals) =>
314(
315 name?: string
316): Config.Config<Literals[number]> => {
317 const valuesString = literals.map(String).join(", ")
318 const config = primitive(`one of (${valuesString})`, (text) => {
319 const found = literals.find((value) => String(value) === text)
320 if (found === undefined) {
321 return Either.left(
322 configError.InvalidData(
323 [],
324 `Expected one of (${valuesString}) but received ${formatUnknown(text)}`
325 )
326 )
327 }
328 return Either.right(found)
329 })
330 return name === undefined ? config : nested(config, name)
331}
332
333/** @internal */
334export 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