react-native-console-table
Version:
Display an array of objects (with the same interface) as a table in the terminal.
15 lines (13 loc) • 540 B
text/typescript
import { IlengthColumn, TObj} from '../types';
import { tabObj, lines } from './dataForTable';
/**
* `Формирование строк данных.`
*/
export function formationLine(columnLength: IlengthColumn[], obj: TObj): string {
let line: string = lines.vertical;
columnLength.forEach(objColumnLength => {
const lineValue = String(obj[objColumnLength.key]).padEnd(objColumnLength.length, ' ');
line = line + tabObj.start + lineValue + tabObj.end + lines.vertical;
})
return line;
}