本文整理汇总了TypeScript中text-table.default函数的典型用法代码示例。如果您正苦于以下问题:TypeScript default函数的具体用法?TypeScript default怎么用?TypeScript default使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了default函数的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的TypeScript代码示例。
示例1: widthOfString
results.forEach(function(result) {
const messages = result.messages;
if (messages.length === 0) {
return;
}
total += messages.length;
output += chalk.underline(result.filePath) + "\n";
output +=
table(
messages.map(function(message) {
let messageType;
// fixable
const fixableIcon = message.fix ? chalk[greenColor].bold("\u2713 ") : "";
if (message.fix) {
totalFixable++;
}
if ((message as any).fatal || message.severity === 2) {
messageType = fixableIcon + chalk.red("error");
summaryColor = "red";
errors++;
} else {
messageType = fixableIcon + chalk.yellow("warning");
warnings++;
}
return [
"",
message.line || 0,
message.column || 0,
messageType,
message.message.replace(/\.$/, ""),
chalk.gray(message.ruleId || "")
];
}),
{
align: ["", "r", "l"],
stringLength: function(str: string) {
const lines = chalk.stripColor(str).split("\n");
return Math.max.apply(
null,
lines.map(function(line: string) {
return widthOfString(line);
})
);
}
}
)
.split("\n")
.map(function(el: string) {
return el.replace(/(\d+)\s+(\d+)/, function(_, p1, p2) {
return chalk.gray(p1 + ":" + p2);
});
})
.join("\n") + "\n\n";
});
示例2: widthOfString
results.forEach(function(result) {
if (!result.applyingMessages || !result.remainingMessages) {
return;
}
const messages = result.applyingMessages;
// still error count
const remainingMessages = result.remainingMessages;
errors += remainingMessages.length;
if (messages.length === 0) {
return;
}
output += `${chalk.underline(result.filePath)}\n`;
output += `${table(
messages.map(function(message) {
// fixable
totalFixed++;
const messageType = chalk[greenColor].bold("\u2714 ");
return [
"",
message.line || 0,
message.column || 0,
messageType,
message.message.replace(/\.$/, ""),
chalk.gray(message.ruleId || "")
];
}),
{
align: ["", "r", "l"],
stringLength: (str: string) => {
const lines = chalk.stripColor(str).split("\n");
return Math.max.apply(
null,
lines.map(function(line: string) {
return widthOfString(line);
})
);
}
}
)
.split("\n")
.map(function(el: string) {
return el.replace(/(\d+)\s+(\d+)/, function(_m, p1, p2) {
return chalk.gray(`${p1}:${p2}`);
});
})
.join("\n")}\n\n`;
});
示例3: textTable
const tableB = (
rows: Array<Array<{}>>,
options?: {
hsep?: string;
align?: Array<'l' | 'r' | 'c' | '.'>;
stringLength?(str: string): number;
}) => textTable(rows, {
...options,
...(
typeof options === 'undefined' ||
typeof options.stringLength === 'undefined'
? { stringLength: eaw.length.bind(eaw) }
: {}
)
});
示例4: test
test(category + 'original text-table', () => {
assert.deepEqual(
textTable(
[
['いろは', '123'],
['abc', '456']
],
{
align: ['l', 'r']
})
,
[
'いろは 123',
'abc 456'
].join('\n')
);
}),
示例5: generateFailureStrings
private generateFailureStrings(): string {
var failures = [];
if (this.options.sort) {
this.ruleFailures = _.sortBy(this.ruleFailures, function (n) {
return n.startPosition.line;
});
}
this.ruleFailures.forEach((failure: RuleFailure) => {
// Error positions are zero-based from tslint, and must be incremented by 1
failures.push([
" ",
chalk.gray("line " + (failure.getStartPosition().line + 1)),
chalk.gray("col " + (failure.getStartPosition().character + 1)),
chalk.red(failure.getFailure())
]);
});
return table(failures, { align: [ "l", "l", "l", "l" ] });
}