本文整理汇总了TypeScript中strip-ansi.default方法的典型用法代码示例。如果您正苦于以下问题:TypeScript strip-ansi.default方法的具体用法?TypeScript strip-ansi.default怎么用?TypeScript strip-ansi.default使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类strip-ansi
的用法示例。
在下文中一共展示了strip-ansi.default方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的TypeScript代码示例。
示例1: writeLine
//#endregion
/**
* adds the text to the reporters output stream
*
* @param {string} text
*/
protected writeLine(text: string): void {
if (text) {
if (!this.mochaOptions.useColors) {
// colors are added by default, setting chalk.level can affect other reporters
// so remove colors if no-color specified
text = strip(text);
}
console.log(text);
}
}
示例2: write
/**
* adds the text to the reporters output stream
* without a line return
*
* @param {string} text
*/
protected write(text: string): void {
if (text) {
if (!this.mochaOptions.useColors) {
// colors are added by default, setting chalk.level can affect other reporters
// so remove colors if no-color specified
text = strip(text);
}
// Output without a line return
process.stdout.write(text);
}
}
示例3: buildTableOutput
export function buildTableOutput(
rows: TableRow[],
{separators = ' ' as string | string[], indent = 0 as string | number} = {},
): string {
let maxTextLengths: number[] = [];
for (let row of rows) {
let lastNoneEmptyIndex = 0;
for (let i = 0; i < row.length; i++) {
let text = row[i] || '';
let textLength = stripAnsi(text).length;
if (textLength) {
lastNoneEmptyIndex = i;
}
if (maxTextLengths.length > i) {
maxTextLengths[i] = Math.max(maxTextLengths[i], textLength);
} else {
maxTextLengths[i] = textLength;
}
}
row.splice(lastNoneEmptyIndex + 1);
}
let indentStr =
typeof indent === 'string' ? indent : new Array(indent + 1).join(' ');
return (
// tslint:disable-next-line:prefer-template
rows
.map(row => {
let line = indentStr;
for (let i = 0; i < row.length; i++) {
let text = row[i] || '';
let textLength = stripAnsi(text).length;
let maxLength = maxTextLengths[i];
line += text;
line += new Array(maxLength - textLength + 1).join(' ');
if (i < row.length - 1) {
if (typeof separators === 'string') {
line += separators;
} else {
line += separators[i];
}
}
}
return line;
})
.join('\n') + '\n'
);
}
示例4: stripAnsi
.map(row => {
let line = indentStr;
for (let i = 0; i < row.length; i++) {
let text = row[i] || '';
let textLength = stripAnsi(text).length;
let maxLength = maxTextLengths[i];
line += text;
line += new Array(maxLength - textLength + 1).join(' ');
if (i < row.length - 1) {
if (typeof separators === 'string') {
line += separators;
} else {
line += separators[i];
}
}
}
return line;
})
示例5: stripAnsi
_lines(s: string): number {
return stripAnsi(s)
.split('\n')
.map(l => Math.ceil(l.length / this.width))
.reduce((c, i) => c + i, 0)
}
示例6: pad
function pad(str: string, length: number) {
const visibleLength = stripAnsi(str).length
const diff = length - visibleLength
return str + ' '.repeat(Math.max(0, diff))
}
示例7: calcWidth
function calcWidth(cell) {
const lines = stripAnsi(cell).split(/[\r\n]+/)
const lineLengths = lines.map(property('length'))
return Math.max.apply(Math, lineLengths)
}
示例8: it
it('List PRs `gh pr --detailed`', done => {
// strip ansi characters so it doesn't fail on Travis
expect(stripAnsi(runCmd('gh pr --detailed'))).toMatchSnapshot()
done()
})