json-to-table-format
Version:
A module for converting JSON data into a tabular format.
14 lines (11 loc) • 473 B
text/typescript
import { getStartPoints, getRows, getData, TableStyle } from "./lib";
function jsontoTable(params: any, style: TableStyle = "simple"): string {
const data = getData(params);
const headers = Object.keys(data[0]);
const startPoints = getStartPoints(data, headers);
const rows = getRows(data, headers, startPoints, style);
return rows.join("\n");
}
// Export for both CommonJS and ES6 compatibility
export default jsontoTable;
export { jsontoTable };