MCPcopy
hub / github.com/Effect-TS/effect / goMemo

Function goMemo

packages/effect/src/ParseResult.ts:752–770  ·  view source on GitHub ↗
(ast: AST.AST, isDecoding: boolean)

Source from the content-addressed store, hash-verified

750)
751
752const goMemo = (ast: AST.AST, isDecoding: boolean): Parser => {
753 const memoMap = isDecoding ? decodeMemoMap : encodeMemoMap
754 const memo = memoMap.get(ast)
755 if (memo) {
756 return memo
757 }
758 const raw = go(ast, isDecoding)
759 const parseOptionsAnnotation = AST.getParseOptionsAnnotation(ast)
760 const parserWithOptions: Parser = Option.isSome(parseOptionsAnnotation)
761 ? (i, options) => raw(i, mergeInternalOptions(options, parseOptionsAnnotation.value))
762 : raw
763 const decodingFallbackAnnotation = AST.getDecodingFallbackAnnotation(ast)
764 const parser: Parser = isDecoding && Option.isSome(decodingFallbackAnnotation)
765 ? (i, options) =>
766 handleForbidden(orElse(parserWithOptions(i, options), decodingFallbackAnnotation.value), ast, i, options)
767 : parserWithOptions
768 memoMap.set(ast, parser)
769 return parser
770}
771
772const getConcurrency = (ast: AST.AST): Concurrency | undefined =>
773 Option.getOrUndefined(AST.getConcurrencyAnnotation(ast))

Callers 5

getEitherFunction · 0.85
getEffectFunction · 0.85
isFunction · 0.85
assertsFunction · 0.85
goFunction · 0.85

Calls 7

mergeInternalOptionsFunction · 0.85
handleForbiddenFunction · 0.85
orElseFunction · 0.85
goFunction · 0.70
getMethod · 0.65
setMethod · 0.65
rawFunction · 0.50

Tested by

no test coverage detected