machines/projects/Printhead/firmware/node/src/format.ts
2023-11-12 21:43:05 +01:00

19 lines
610 B
TypeScript

import { Options, OutputFormat } from "./types";
import { error } from "./log";
export const render = (result: any, options: Options) => {
switch (options.format) {
case OutputFormat.text: {
//@TODO: human readable format
return JSON.stringify(result, null, 2);
}
case OutputFormat.json: {
return JSON.stringify(result, null, 2);
}
default: {
//private, should never happen since options had to be sanitized
error('format::render Invalid value in options.format');
return '';
}
}
}