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

Function resolveTag

packages/effect/src/encoding/Yaml.ts:373–386  ·  view source on GitHub ↗
(
  tag: string,
  value: unknown,
  plain: string | undefined,
  fail: (message: string) => never
)

Source from the content-addressed store, hash-verified

371// node is a plain scalar; quoted and block scalars are already strings, and an
372// empty node is the empty string.
373const resolveTag = (
374 tag: string,
375 value: unknown,
376 plain: string | undefined,
377 fail: (message: string) => never
378): unknown => {
379 const collection = typeof value === "object" && value !== null
380 if (tag === "!!seq" || tag === "!!map") {
381 if (!collection || Array.isArray(value) !== (tag === "!!seq")) fail(`Node does not match the YAML tag ${tag}`)
382 return value
383 }
384 if (collection) fail(`A collection does not match the YAML tag ${tag}`)
385 return resolveScalarTag(tag, plain ?? (typeof value === "string" ? value : ""), fail)
386}
387
388const isExplicitKey = (text: string): boolean =>
389 text.charCodeAt(0) === 63 && (text.length === 1 || isWhiteCode(text.charCodeAt(1)))

Callers 2

parseTaggedValueMethod · 0.85
parseNodeValueMethod · 0.85

Calls 2

resolveScalarTagFunction · 0.85
failFunction · 0.70

Tested by

no test coverage detected