當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。