本文整理汇总了TypeScript中underscore.string.default类的典型用法代码示例。如果您正苦于以下问题:TypeScript string.default类的具体用法?TypeScript string.default怎么用?TypeScript string.default使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了string.default类的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的TypeScript代码示例。
示例1: findRule
export function findRule(name: string, rulesDirectory?: string) {
var camelizedName = transformName(name);
// first check for core rules
var Rule = loadRule(CORE_RULES_DIRECTORY, camelizedName);
if (Rule) {
return Rule;
}
// then check for rules within the first level of rulesDirectory
if (rulesDirectory) {
Rule = loadRule(rulesDirectory, camelizedName);
if (Rule) {
return Rule;
}
}
// finally check for rules within the first level of directories,
// using dash prefixes as the sub-directory names
if (rulesDirectory) {
var subDirectory = _s.strLeft(rulesDirectory, "-");
var ruleName = _s.strRight(rulesDirectory, "-");
if (subDirectory !== rulesDirectory && ruleName !== rulesDirectory) {
camelizedName = transformName(ruleName);
Rule = loadRule(rulesDirectory, subDirectory, camelizedName);
if (Rule) {
return Rule;
}
}
}
return undefined;
}
开发者ID:CalvinFernandez,项目名称:tslint,代码行数:33,代码来源:ruleLoader.ts
示例2: Date
inquirer.prompt(prompts).then(answers => {
if (!answers.moveon) {
return;
}
let today = new Date(),
year = today.getFullYear().toString();
answers.appVersion = [
'v0',
year.slice(2),
(today.getMonth() + 1) + padLeft(today.getDate())
].join('.');
answers.appNameSlug = _.slugify(answers.appName);
answers.appTitle = startCase(answers.appName).split(' ').join('');
answers.appYear = year;
gulp.src([
`${__dirname}/../templates/common/**`,
`${__dirname}/../templates/${answers.projectType}-package/**`
])
.pipe(template(answers))
.pipe(rename(file => {
if (file.basename[0] === '_') {
file.basename = '.' + file.basename.slice(1);
}
}))
.pipe(conflict('./'))
.pipe(gulp.dest('./'))
.on('end', () => {
this.log.info(`Successfully created LabShare ${answers.projectType} package...`);
});
});
开发者ID:LabShare,项目名称:lsc,代码行数:33,代码来源:package.ts
示例3: transformName
function transformName(name: string) {
// camelize strips out leading and trailing underscores and dashes, so make sure they aren't passed to camelize
// the regex matches the groups (leading underscores and dashes)(other characters)(trailing underscores and dashes)
var nameMatch = name.match(/^([-_]*)(.*?)([-_]*)$/);
if (nameMatch == null) {
return name + "Rule";
}
return nameMatch[1] + _s.camelize(nameMatch[2]) + nameMatch[3] + "Rule";
}
开发者ID:CalvinFernandez,项目名称:tslint,代码行数:9,代码来源:ruleLoader.ts
示例4: findFormatter
export function findFormatter(name: string, formattersDirectory?: string) {
var camelizedName = _s.camelize(name + "Formatter");
// first check for core formatters
var Formatter = loadFormatter(CORE_FORMATTERS_DIRECTORY, camelizedName);
if (Formatter) {
return Formatter;
}
// then check for rules within the first level of rulesDirectory
if (formattersDirectory) {
Formatter = loadFormatter(formattersDirectory, camelizedName);
if (Formatter) {
return Formatter;
}
}
// else try to resolve as module
return loadFormatterModule(name);
}
开发者ID:Bartvds,项目名称:tslint,代码行数:20,代码来源:formatterLoader.ts
示例5: normalize
///<reference path='node/node.d.ts' />
var _: any = require('underscore');
var str: any = require('underscore.string');
// Mix in non-conflict functions to Underscore namespace if you want
_.mixin(str.exports());
function normalize(text: string): string {
return _.trim(text.replace(/(\r\n)/g, '\n').replace(/(\r)/g, '\n'));
}
export function isCorrect(actual, expected) {
console.log(normalize(expected));
console.log(normalize(actual));
return normalize(actual) === normalize(expected);
};
开发者ID:TakenokoChocoHolic,项目名称:CodeTengoku,代码行数:16,代码来源:judge.ts
示例6: getHighlightedCode
function getHighlightedCode(lscAst: ILambdaScriptAstNode, lambdaScriptCode: string) {
const codeByLines = _str.lines(lambdaScriptCode),
colorActions = traverse(lscAst)
.reduce(function(colorActions: ILineColorAction[], astNode: ILambdaScriptAstNode) {
const color = colorMap[astNode.type];
if (color) {
const colorFn = chalk[color].bind(chalk),
locKey = alternateLocMap[astNode.type] || 'loc',
// I'm just using _.result to avoid TS7017
loc: ILoc = _.result(astNode, locKey);
/**
* Originally, I just colored as soon as I found a node. However, this does not work,
* because other coloring may have occurred on the line already, which will offset our
* column indices. And it is not sufficient just to drop all color from the line and
* see what the length difference is, because some of that color could be *after* our
* column indices and thus irrelevant. To solve this, we will gather all the colorings
* we want to do, and then apply them in sorted order. This makes the offset caclulation trivial.
*/
return colorActions.concat({
// I don't know why but jison does not 0-index the line number.
lineIndex: loc.first_line - 1,
colStart: loc.first_column,
colEnd: loc.last_column,
colorFn: colorFn
});
}
return colorActions;
}, []),
coloredCode = _(colorActions)
.sortByAll(['lineIndex', 'colStart'])
.reduce(function(lines: string[], colorAction: ILineColorAction) {
const linesClone = _.clone(lines),
lineToColor = linesClone[colorAction.lineIndex],
existingColorOffset = lineToColor.length - chalk.stripColor(lineToColor).length,
colStartWithOffset = colorAction.colStart + existingColorOffset,
colEndWithOffset = colorAction.colEnd + existingColorOffset;
// One potential way to fail fast here would be to detect when we are coloring
// over an existing highlight. I have yet to encounter a case where that was expected behavior.
linesClone[colorAction.lineIndex] =
lineToColor.slice(0, colStartWithOffset) +
colorAction.colorFn(lineToColor.slice(colStartWithOffset, colEndWithOffset)) +
lineToColor.slice(colEndWithOffset);
logger.debug({
original: lines[colorAction.lineIndex],
colored: linesClone[colorAction.lineIndex]
}, 'Coloring line');
return linesClone;
}, codeByLines);
return coloredCode.join(os.EOL);
}
开发者ID:NickHeiner,项目名称:lambdascript,代码行数:63,代码来源:get-highlighted-code.ts
注:本文中的underscore.string.default类示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论