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

Method constructor

packages/effect/src/SchemaAST.ts:1145–1173  ·  view source on GitHub ↗
(
    parts: ReadonlyArray<AST>,
    annotations?: Schema.Annotations.Annotations,
    checks?: Checks,
    encoding?: Encoding,
    context?: Context
  )

Source from the content-addressed store, hash-verified

1143 readonly suffixLengths: ReadonlyArray<number>
1144
1145 constructor(
1146 parts: ReadonlyArray<AST>,
1147 annotations?: Schema.Annotations.Annotations,
1148 checks?: Checks,
1149 encoding?: Encoding,
1150 context?: Context
1151 ) {
1152 super(annotations, checks, encoding, context)
1153 const encodedParts: Array<TemplateLiteralPart> = []
1154 const literals: Array<string | undefined> = []
1155 for (const part of parts) {
1156 const encoded = toEncoded(part)
1157 if (isTemplateLiteralPart(encoded)) {
1158 encodedParts.push(encoded)
1159 literals.push(encoded._tag === "Literal" ? globalThis.String(encoded.literal) : undefined)
1160 } else {
1161 throw new Error(`Invalid TemplateLiteral part ${encoded._tag}`)
1162 }
1163 }
1164 const suffixLengths = new Array<number>(encodedParts.length + 1)
1165 suffixLengths[encodedParts.length] = 0
1166 for (let i = encodedParts.length - 1; i >= 0; i--) {
1167 suffixLengths[i] = suffixLengths[i + 1] + (literals[i]?.length ?? 0)
1168 }
1169 this.parts = parts
1170 this.encodedParts = encodedParts
1171 this.literals = literals
1172 this.suffixLengths = suffixLengths
1173 }
1174 /** @internal */
1175 getParser(compile: SchemaParser.Compiler): SchemaParser.Parser {
1176 const parser = compile(this.asTemplateLiteralParser())

Callers

nothing calls this directly

Calls 3

toEncodedInterface · 0.85
isTemplateLiteralPartFunction · 0.85
pushMethod · 0.80

Tested by

no test coverage detected