• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

TypeScript underscore.string.default类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了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;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
TypeScript undertaker.task函数代码示例发布时间:2022-05-25
下一篇:
TypeScript underscore.string类代码示例发布时间:2022-05-25
热门推荐
热门话题
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap