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


TypeScript keyed.tryAdd函数代码示例

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


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

示例1: shouldImmediateNodeBeConsidered

function shouldImmediateNodeBeConsidered(ruleKey: string, node: ts.Node, per: PerNode): boolean {
    const id = node.id;
    if (id !== undefined) {
        // AB: nodes without ID should probably be considere (not sure what it means)
        return true;
    } else {
        const key = '_' + id;
        const previousInstructions = bk.at(per.nodes, key);
        if (previousInstructions === undefined) {
            const comments = leadingCommentsStrippedOutOf(node);
            if (comments.length > 0) {
                const freshlyMadeInstructions = instructionsOutOfComments(comments);
                bk.tryAdd(
                    per.nodes,
                    key,
                    freshlyMadeInstructions
                );
                return ba.hasAnyLike(freshlyMadeInstructions, ruleKey, bb.areStringsEqual) ? false : true;
            } else {
                // AB: there are no comments assigned to the node, it means no special instructions
                bk.tryAdd(
                    per.nodes,
                    key,
                    comments // AB: we can reuse empty comments for empty special instructions
                );
                return true;
            }
        } else {
            // AB: we got some special instructions previously assigned to the node
            return ba.hasAnyLike(previousInstructions, ruleKey, bb.areStringsEqual) ? false : true;
        }
    }
}
开发者ID:aleksey-bykov,项目名称:linting,代码行数:33,代码来源:per-node-rule.ts

示例2: skipArgument

 function skipArgument(parsing: LooselyParsing): $Taken<null> {
     const { parsed, options } = parsing;
     if (isLooselyParsedParameter(parsed)) {
         const { result } = parsed;
         const args = parsed.isFull ? result.fullArgs : result.shortArgs;
         if (bk.tryAdd(args, parsed.name, null)) {
             return luck(
                 looselyParsingFrom(
                     options,
                     result
                 ),
                 null
             );
         } else {
             return fail(unexpectedParameterName, 'A parameter with the same "' + parsed.name + '" was already specified.');
         }
     } else {
         return toFailedToFindBuilderInParameterState();
     }
 }
开发者ID:aleksey-bykov,项目名称:commandlining,代码行数:20,代码来源:loose-builder.ts

示例3: takeArgument

    function takeArgument(parsing: LooselyParsing, token: Token): $Taken<AfterArgument> {
        const { parsed, options } = parsing;
        if (isLooselyParsedParameter(parsed)) {
            const { result } = parsed;
            const args = parsed.isFull ? result.fullArgs : result.shortArgs;
            const value = tokenToString(token)
            if (bk.tryAdd(args, parsed.name, value)) {

                return luck(
                    looselyParsingFrom(
                        options,
                        result
                    ),
                    mightNeedParameter
                );
            } else {
                return fail(unexpectedParameterName, 'A parameter with the same "' + parsed.name + '" was already specified.');
            }
        } else {
            return toFailedToFindBuilderInParameterState();
        }
    }
开发者ID:aleksey-bykov,项目名称:commandlining,代码行数:22,代码来源:loose-builder.ts

示例4: tryAdd

 (result, value) => (
     void tryAdd(result, toArgument(value), value),
     result
 )
开发者ID:aleksey-bykov,项目名称:commandlining,代码行数:4,代码来源:arguments.ts


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