cloudcmd
Version:
File manager for the web with console and editor
37 lines (30 loc) • 694 B
JavaScript
import {
table,
getBorderCharacters,
} from 'table';
export const showConfig = (config) => {
check(config);
const data = Object
.keys(config)
.map((name) => [
name,
config[name],
]);
if (!data.length)
return '';
return table(data, {
columns: {
1: {
width: 30,
truncate: 30,
},
},
border: getBorderCharacters('ramac'),
});
};
function check(config) {
if (!config)
throw Error('config could not be empty!');
if (typeof config !== 'object')
throw Error('config should be an object!');
}