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

Function parseParameter

packages/effect/src/SchemaAST.ts:4604–4643  ·  view source on GitHub ↗
(ast: AST)

Source from the content-addressed store, hash-verified

4602}
4603
4604function parseParameter(ast: AST): {
4605 literals: ReadonlyArray<PropertyKey>
4606 parameters: ReadonlyArray<AST>
4607} {
4608 const literals: Array<PropertyKey> = []
4609 const parameters: Array<AST> = []
4610 function addLiteral(literal: PropertyKey) {
4611 if (!literals.includes(literal)) {
4612 literals.push(literal)
4613 }
4614 }
4615 function go(ast: AST) {
4616 switch (ast._tag) {
4617 case "Literal":
4618 if (Predicate.isPropertyKey(ast.literal)) {
4619 addLiteral(ast.literal)
4620 }
4621 return
4622 case "UniqueSymbol":
4623 addLiteral(ast.symbol)
4624 return
4625 case "Enum":
4626 for (const [, value] of ast.enums) {
4627 addLiteral(value)
4628 }
4629 return
4630 case "Never":
4631 return
4632 case "Union":
4633 for (let i = 0; i < ast.types.length; i++) {
4634 go(ast.types[i])
4635 }
4636 return
4637 default:
4638 parameters.push(ast)
4639 }
4640 }
4641 go(ast)
4642 return { literals, parameters }
4643}
4644
4645/** @internal */
4646export function record(key: AST, value: AST): Objects {

Callers 1

recordFunction · 0.85

Calls 1

goFunction · 0.70

Tested by

no test coverage detected