format with prettier 3

This commit is contained in:
Kyle Corbitt
2023-07-08 22:12:47 -07:00
parent 6b32619e87
commit a8db6cadfd
34 changed files with 201 additions and 480 deletions

View File

@@ -8,17 +8,20 @@ export function fillTemplate(template: string, variables: VariableMap): string {
export function fillTemplateJson<T extends JSONSerializable>(
template: T,
variables: VariableMap
variables: VariableMap,
): T {
if (typeof template === "string") {
return fillTemplate(template, variables) as T;
} else if (Array.isArray(template)) {
return template.map((item) => fillTemplateJson(item, variables)) as T;
} else if (typeof template === "object" && template !== null) {
return Object.keys(template).reduce((acc, key) => {
acc[key] = fillTemplateJson(template[key] as JSONSerializable, variables);
return acc;
}, {} as { [key: string]: JSONSerializable } & T);
return Object.keys(template).reduce(
(acc, key) => {
acc[key] = fillTemplateJson(template[key] as JSONSerializable, variables);
return acc;
},
{} as { [key: string]: JSONSerializable } & T,
);
} else {
return template;
}