本文整理汇总了TypeScript中chalk.inverse函数的典型用法代码示例。如果您正苦于以下问题:TypeScript inverse函数的具体用法?TypeScript inverse怎么用?TypeScript inverse使用的例子?那么, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了inverse函数的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的TypeScript代码示例。
示例1: if
const formatMessage = (message: string): string => {
let lines = message.split('\n');
if (lines.length > 2 && lines[1] === '') {
lines.splice(1, 1);
}
if (lines[0].lastIndexOf('!') >= 0) {
lines[0] = lines[0].substr(lines[0].lastIndexOf('!') + 1);
}
lines = lines.filter(line => line.indexOf(' @ ') !== 0);
if (!lines[0] || !lines[1]) {
return lines.join('\n');
}
if (lines[1].indexOf('Module not found: ') === 0) {
lines = [
lines[0],
lines[1]
.replace("Cannot resolve 'file' or 'directory' ", '')
.replace('Cannot resolve module ', '')
.replace('Error: ', '')
.replace('[CaseSensitivePathsPlugin] ', '')
];
} else if (lines[1].indexOf('Module build failed: ') === 0) {
lines[1] = lines[1].replace(
'Module build failed: SyntaxError:',
syntaxErrorLabel
);
}
const exportError = /\s*(.+?)\s*(")?export '(.+?)' was not found in '(.+?)'/;
if (lines[1].match(exportError)) {
lines[1] = lines[1].replace(
exportError,
"$1 '$4' does not contain an export named '$3'."
);
}
lines[0] = chalk.inverse(lines[0]);
message = lines.join('\n');
message = message.replace(
/^\s*at\s((?!webpack:).)*:\d+:\d+[\s)]*(\n|$)/gm,
''
);
return message.trim();
}
示例2:
renderer.codespan = (code) => {
return chalk.inverse(code);
};
示例3:
export const highlightTrailingWhitespace = (text: string): string =>
text.replace(/\s+$/gm, chalk.inverse('$&'));
示例4:
choices: onlineStreams.map(stream => `${chalk.inverse(stream.user_name)} - ${chalk.gray(stream.title)}`)