当前位置: 首页>>代码示例>>TypeScript>>正文


TypeScript text-table.default函数代码示例

本文整理汇总了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";
    });
开发者ID:textlint,项目名称:textlint,代码行数:58,代码来源:stylish.ts

示例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`;
    });
开发者ID:textlint,项目名称:textlint,代码行数:49,代码来源:stylish.ts

示例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) }
        : {}
    )
  });
开发者ID:bouzuya,项目名称:table-b,代码行数:15,代码来源:index.ts

示例4: test

 test(category + 'original text-table', () => {
   assert.deepEqual(
     textTable(
       [
         ['いろは', '123'],
         ['abc', '456']
       ],
       {
         align: ['l', 'r']
       })
     ,
     [
       'いろは  123',
       'abc  456'
     ].join('\n')
   );
 }),
开发者ID:bouzuya,项目名称:table-b,代码行数:17,代码来源:index.ts

示例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" ] });
    }
开发者ID:adamfitzpatrick,项目名称:tslint-stylish,代码行数:21,代码来源:reporter.ts


注:本文中的text-table.default函数示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。