MCPcopy Index your code
hub / github.com/glideapps/quicktype / sourceLineLength

Function sourceLineLength

src/Source.ts:142–163  ·  view source on GitHub ↗
(source: Source, names: Map<Name, string>)

Source from the content-addressed store, hash-verified

140}
141
142function sourceLineLength(source: Source, names: Map<Name, string>): number {
143 switch (source.kind) {
144 case "text":
145 return source.text.length;
146 case "newline":
147 return panic("Newline must not occur within a line.");
148 case "sequence":
149 return source.sequence
150 .map((s: Source) => sourceLineLength(s, names))
151 .reduce((a: number, b: number) => a + b, 0);
152 case "table":
153 return panic("Table must not occur within a line.");
154 case "annotated":
155 return sourceLineLength(source.source, names);
156 case "name":
157 return defined(names.get(source.named)).length;
158 case "modified":
159 return serializeRenderResult({ rootSource: source, names }, "").lines.join("\n").length;
160 default:
161 return assertNever(source);
162 }
163}
164
165export function serializeRenderResult(
166 { rootSource, names }: RenderResult,

Callers 1

serializeToStringArrayFunction · 0.85

Calls 5

panicFunction · 0.90
definedFunction · 0.90
assertNeverFunction · 0.90
serializeRenderResultFunction · 0.85
mapMethod · 0.65

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…