Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
export function format(value: T, fmt = Format.Yaml): string {
value = convertToPrintable(value) || {};
switch (fmt) {
case Format.Json:
return JSON.stringify(value, undefined, 2);
case Format.Json5:
return json5.stringify(value, undefined, 2);
case Format.Yaml:
return yaml.safeDump(value, {
indent: 2,
schema: yaml.JSON_SCHEMA,
sortKeys: true,
});
default:
return assertNever(fmt);
}
}