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


TypeScript pluralize.default函数代码示例

本文整理汇总了TypeScript中pluralize.default函数的典型用法代码示例。如果您正苦于以下问题:TypeScript default函数的具体用法?TypeScript default怎么用?TypeScript default使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。


在下文中一共展示了default函数的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的TypeScript代码示例。

示例1: formatter

/**
 *
 * @param {TextLintResult[]} results
 * @param {TextLintFormatterOption} options
 * @returns {string}
 */
function formatter(results: TextlintResult[], options: TextLintFormatterOption) {
    // default: true
    const useColor = options.color !== undefined ? options.color : true;
    let output = "";
    let total = 0;
    let errors = 0;
    let warnings = 0;
    let totalFixable = 0;
    results.forEach(function(result) {
        const code = require("fs").readFileSync(result.filePath, "utf-8");
        const messages = result.messages;
        if (messages.length === 0) {
            return;
        }
        total += messages.length;
        messages.forEach(function(message) {
            // fixable
            const fixableIcon = message.fix ? chalk[greenColor].bold("\u2713 ") : "";
            if (message.fix) {
                totalFixable++;
            }
            if ((message as any).fatal || message.severity === 2) {
                errors++;
            } else {
                warnings++;
            }
            const r = fixableIcon + prettyError(code, result.filePath, message);
            if (r) {
                output += r + "\n";
            }
        });
    });

    if (total > 0) {
        output += chalk[summaryColor].bold(
            [
                "\u2716 ",
                total,
                pluralize(" problem", total),
                " (",
                errors,
                pluralize(" error", errors),
                ", ",
                warnings,
                pluralize(" warning", warnings),
                ")\n"
            ].join("")
        );
    }

    if (totalFixable > 0) {
        output += chalk[greenColor].bold(
            "✓ " + totalFixable + " fixable " + pluralize("problem", totalFixable) + ".\n"
        );
        output += "Try to run: $ " + chalk.underline("textlint --fix [file]") + "\n";
    }

    if (!useColor) {
        return stripAnsi(output);
    }
    return output;
}
开发者ID:textlint,项目名称:textlint,代码行数:68,代码来源:pretty-error.ts

示例2: GQLField

      const inlineRelationFields = inlineRelations.map(relation => {
        const ambiguousRelations = tc.relations.filter(innerRelation => innerRelation.source_table === relation.source_table && innerRelation.target_table === relation.target_table)
        const remoteColumns = _.intersectionWith(
          tc.columns,
          ambiguousRelations,
          (a, b) => a.name === b.source_column
        )
        
        const selfAmbiguousRelations = ambiguousRelations.filter(relation => relation.source_table === relation.target_table)
        const selfRemoteColumns = _.intersectionWith(
          tc.columns,
          selfAmbiguousRelations,
          (a, b) => a.name === b.source_column
        )

        const relationName = pluralize(relation.source_table) + '_' + pluralize(this.removeIdSuffix(relation.source_column))
        const directives = [
          `@pgRelation(column: "${relation.source_column}")`,
          ...(ambiguousRelations.length > 1 && remoteColumns && remoteColumns.length > 0 ? [`@relation(name: "${upperCamelCase(relationName)}")`] : []),
          ...(selfAmbiguousRelations.length > 0 && selfRemoteColumns && selfRemoteColumns.length > 0 ? [`@relation(name: "${upperCamelCase(relationName)}")`] : [])
        ]

        return new GQLField(
          this.removeIdSuffix(relation.source_column),
          `${this.capitalizeFirstLetter(relation.target_table)}`,
          false,
          directives,
          false,
          "", // TODO: Figure out comment thing for this
          false
        )
      })
开发者ID:nunsie,项目名称:prisma,代码行数:32,代码来源:SDLInferrer.ts

示例3: get

 return viewDfnBitNames.map(bitName => {
   const bValue: number = info[bitName]
   const rName = get(replacers, bitName, bitName)
   const pName = pluralize(rName, bValue)
   const result = bValue.toString() + space + pName
   return result
 }).join(' ')
开发者ID:nskazki,项目名称:pretty-large-ms,代码行数:7,代码来源:index.ts

示例4:

 lodash.forEach(groupedErrors, (errors: Array<any>, fileName: string) => {
   util.log();
   util.log(chalk.bold.underline(fileName));
   lodash.forEach(errors, (err: any) => {
     util.log(
       ' ',
       chalk.bold.gray('line ' + err.line),
       chalk.bold.gray('col ' + err.column),
       chalk.blue(err.message)
     );
     notification.notify({
       group: fileName,
       title: fileName,
       message: 'Line ' + err.line + ' Col ' + err.column + ' ' + err.message,
       sound: 'Funk',
       sender: 'com.apple.Terminal'
     });
   });
   util.log();
   util.log(
     chalk.red(logSymbols.error),
     chalk.bold.red(errors.length.toString()),
     chalk.bold.red(pluralize('problem', errors.length))
   );
   util.log();
 });
开发者ID:ngbinh,项目名称:angular-typescript,代码行数:26,代码来源:gulpfile.ts

示例5: pluralizeLastWord

export function pluralizeLastWord(name:string) {
    const parts = getWords(name);
    if (parts.length == 0) {
        return name;
    }
    const lastWord = parts.pop();
    const lastPos = name.lastIndexOf(lastWord);

    return name.substr(0, lastPos) + plural(lastWord) + name.substr(lastPos + lastWord.length);
}
开发者ID:cevek,项目名称:gen-templates,代码行数:10,代码来源:strings.ts

示例6: formatter

function formatter(report: any) {
    let result = "";
    let errorCount = 0;
    let warningCount = 0;

    report.forEach(function(fileReport: any) {
        errorCount += fileReport.errorCount;
        warningCount += fileReport.warningCount;
    });

    if (errorCount || warningCount) {
        result = drawReport(report);
    }

    result +=
        "\n" +
        table(
            [
                [chalk.red(pluralize("Error", errorCount, true))],
                [chalk.yellow(pluralize("Warning", warningCount, true))]
            ],
            {
                columns: {
                    0: {
                        width: 110,
                        wrapWord: true
                    }
                },
                drawHorizontalLine: function() {
                    return true;
                }
            }
        );

    return result;
}
开发者ID:textlint,项目名称:textlint,代码行数:36,代码来源:table.ts

示例7: function

 ws.on('message', function(data, flags) {
     // flags.binary will be set if a binary data is received.
     // flags.masked will be set if the data was masked.
     let parsed = JSON.parse(data);
     if(parsed.kind === "code error") {
         console.error(colors.red(parsed.data));
     } else if(parsed.kind === "code result") {
         console.log(resultsTable(parsed.data));
     } else if(parsed.kind === "code changeset") {
         console.log(`${parsed.data} ${pluralize("row", parsed.data)} added/removed`);
     } else {
         return;
     }
     console.log("");
     console.log(separator);
     console.log("");
     recurse();
 });
开发者ID:AtnNn,项目名称:Eve,代码行数:18,代码来源:repl.ts

示例8: pluralize

 transform(count:number, args:any[]) {
   if(!args[0]) throw "Specify a word to pluralize";
   return pluralize(args[0], count, true);
 }
开发者ID:windwang,项目名称:angular2-app,代码行数:4,代码来源:PluralizePipe.ts


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