本文整理汇总了TypeScript中chalk.stripColor函数的典型用法代码示例。如果您正苦于以下问题:TypeScript stripColor函数的具体用法?TypeScript stripColor怎么用?TypeScript stripColor使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了stripColor函数的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的TypeScript代码示例。
示例1: it
it('logs to the console with a timestamp', () => {
logger.info('example');
expect(stripColor(consoleLogSpy.calls.first().args[0]))
.toMatch(/\[\d{2}:\d{2}:\d{2}\]/);
expect(stripColor(consoleLogSpy.calls.first().args[1]))
.toEqual('example');
});
示例2:
.reduce(function(lines: string[], colorAction: ILineColorAction) {
const linesClone = _.clone(lines),
lineToColor = linesClone[colorAction.lineIndex],
existingColorOffset = lineToColor.length - chalk.stripColor(lineToColor).length,
colStartWithOffset = colorAction.colStart + existingColorOffset,
colEndWithOffset = colorAction.colEnd + existingColorOffset;
// One potential way to fail fast here would be to detect when we are coloring
// over an existing highlight. I have yet to encounter a case where that was expected behavior.
linesClone[colorAction.lineIndex] =
lineToColor.slice(0, colStartWithOffset) +
colorAction.colorFn(lineToColor.slice(colStartWithOffset, colEndWithOffset)) +
lineToColor.slice(colEndWithOffset);
logger.debug({
original: lines[colorAction.lineIndex],
colored: linesClone[colorAction.lineIndex]
}, 'Coloring line');
return linesClone;
}, codeByLines);
示例3: function
stringLength: function(str: string) {
const lines = chalk.stripColor(str).split("\n");
return Math.max.apply(
null,
lines.map(function(line: string) {
return widthOfString(line);
})
);
}
示例4: function
console.log = function (): void { consoleBuffer.push(chalk.stripColor(Array.prototype.slice.call(arguments, 0).join(" "))); };