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 };
