本文整理汇总了TypeScript中table.table函数的典型用法代码示例。如果您正苦于以下问题:TypeScript table函数的具体用法?TypeScript table怎么用?TypeScript table使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了table函数的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的TypeScript代码示例。
示例1: async
export default async (props: ProjectsProps, env: SystemEnvironment): Promise<void> => {
const {resolver, out} = env
try {
const projects = await fetchProjects(resolver)
const currentProjectId = resolver.exists(graphcoolProjectFileName) ?
readProjectIdFromProjectFile(resolver, graphcoolProjectFileName) :
null
const data = projects.map(project => {
const isCurrentProject = currentProjectId !== null && (currentProjectId === project.projectId || currentProjectId === project.alias)
return [isCurrentProject ? '*' : ' ', `${project.alias || project.projectId} `, project.name, regionEnumToOption(project.region)]
})
const output = table(data, {
border: getBorderCharacters('void'),
columnDefault: {
paddingLeft: '0',
paddingRight: '2',
},
drawHorizontalLine: () => false,
}).trimRight()
out.write(output)
} catch (e) {
throw new Error(`${couldNotFetchProjectsMessage} ${e.message}`)
}
}
示例2:
import * as table from 'table';
const border: table.JoinStruct = table.getBorderCharacters('norc');
const data = [
['first name', 'last name'],
['jane', 'doe'],
['john', 'doe']
];
const config: table.TableUserConfig = {
border,
columnCount: 1,
drawHorizontalLine: () => true
};
table.table(data, config);
示例3:
const displayColorDiffTable = (diff: string[][]) => {
console.log(table(diff, TABLE_OPTS))
}