MCPcopy Create free account
hub / github.com/glideapps/quicktype / sourcelikeToSource

Function sourcelikeToSource

src/Source.ts:72–96  ·  view source on GitHub ↗
(sl: Sourcelike)

Source from the content-addressed store, hash-verified

70export interface SourcelikeArray extends Array<Sourcelike> {}
71
72export function sourcelikeToSource(sl: Sourcelike): Source {
73 if (sl instanceof Array) {
74 return {
75 kind: "sequence",
76 sequence: List(sl.map(sourcelikeToSource))
77 };
78 }
79 if (typeof sl === "string") {
80 const lines = sl.split("\n");
81 if (lines.length === 1) {
82 return { kind: "text", text: sl };
83 }
84 return {
85 kind: "sequence",
86 sequence: intercalate(
87 newline(),
88 List(lines).map((l: string) => ({ kind: "text", text: l } as Source))
89 ).toList()
90 };
91 }
92 if (sl instanceof Name) {
93 return { kind: "name", named: sl };
94 }
95 return sl;
96}
97
98export function annotated(annotation: AnnotationData, sl: Sourcelike): Source {
99 return {

Callers 5

emitAnnotatedFunction · 0.90
Renderer.tsFile · 0.90
annotatedFunction · 0.85
modifySourceFunction · 0.85

Calls 3

intercalateFunction · 0.90
newlineFunction · 0.85
mapMethod · 0.65

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…