本文整理匯總了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;
}
示例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
)
})
示例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(' ')
示例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();
});
示例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);
}
示例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;
}
示例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();
});
示例8: pluralize
transform(count:number, args:any[]) {
if(!args[0]) throw "Specify a word to pluralize";
return pluralize(args[0], count, true);
}