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


TypeScript estraverse.replace函数代码示例

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


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

示例1: appendNode

    public appendNode (): void {
        estraverse.replace(this.astTree, {
            leave: (node, parent) => {
                switch (node.type) {
                    case 'Program':
                        node.body.push(this.getNode());

                        break;
                }
            }
        });
    }
开发者ID:ManuCutillas,项目名称:javascript-obfuscator,代码行数:12,代码来源:UnicodeArrayRotateFunctionNode.ts

示例2:

            .forEach((property: IPropertyNode) => {
                estraverse.replace(property.key, {
                    leave: (node: INode, parentNode: INode): any => {
                        if (Nodes.isLiteralNode(node)) {
                            this.obfuscateLiteralPropertyKey(node);

                            return;
                        }

                        if (Nodes.isIdentifierNode(node)) {
                            this.obfuscateIdentifierPropertyKey(node);
                        }
                    }
                });
            });
开发者ID:surjit,项目名称:javascript-obfuscator,代码行数:15,代码来源:ObjectExpressionObfuscator.ts

示例3: switch

        objectExpressionNode.properties.forEach((property) => {
            estraverse.replace(property.key, {
                leave: (node, parentNode) => {
                    switch (node.type) {
                        case 'Literal':
                            this.literalNodeController(node);

                            break;

                        case 'Identifier':
                            this.identifierNodeController(node);

                            break;
                    }
                }
            });
        });
开发者ID:ManuCutillas,项目名称:javascript-obfuscator,代码行数:17,代码来源:ObjectExpressionObfuscator.ts

示例4: obfuscateNode

    /**
     * @param memberExpressionNode
     */
    public obfuscateNode (memberExpressionNode: IMemberExpressionNode): void {
        estraverse.replace(memberExpressionNode.property, {
            leave: (node: INode, parentNode: INode): any => {
                if (Nodes.isLiteralNode(node)) {
                    this.obfuscateLiteralProperty(node);

                    return;
                }

                if (Nodes.isIdentifierNode(node)) {
                    if (memberExpressionNode.computed) {
                        return;
                    }

                    memberExpressionNode.computed = true;
                    this.obfuscateIdentifierProperty(node);
                }
            }
        });
    }
开发者ID:surjit,项目名称:javascript-obfuscator,代码行数:23,代码来源:MemberExpressionObfuscator.ts

示例5: function

    files.forEach((file: {src: string[]; dest: string}) => {
      var jsFileContent = fs.readFileSync(file.src[0]).toString(),
        ast = esprima.parse(jsFileContent, {loc: true, range: true});
      // Ensure destination folder exists
      if (!fs.existsSync(path.dirname(file.dest))) {
        grunt.file.mkdir(path.dirname(file.dest));
      }
      var processedAst = estraverse.replace(ast, {
        enter: function(node: any) {
            if (node.type === 'ExpressionStatement' &&
                node.expression.type === 'CallExpression' &&
                remove.indexOf(node.expression.callee.name) > -1) {
                return {type:'EmptyStatement'};
            }
        }
      }), output = escodegen.generate(processedAst, {sourceMap: path.relative(path.dirname(file.dest), file.src[0]), sourceMapWithCode: true});

      var mapDest = file.dest + '.map';
      fs.writeFileSync(mapDest, output.map);
      fs.writeFileSync(file.dest, `${output.code}\n//# sourceMappingURL=${path.basename(file.dest)}.map`);
    });
开发者ID:Warlander,项目名称:doppio,代码行数:21,代码来源:ice-cream.ts

示例6: obfuscateNode

    /**
     * @param memberExpressionNode
     */
    public obfuscateNode (memberExpressionNode: any): void {
        estraverse.replace(memberExpressionNode.property, {
            leave: (node, parentNode) => {
                switch (node.type) {
                    case 'Literal':
                        this.literalNodeController(node);

                        break;

                    case 'Identifier':
                        if (memberExpressionNode.computed) {
                            break;
                        }

                        memberExpressionNode.computed = true;
                        this.identifierNodeController(node);

                        break;
                }
            }
        });
    }
开发者ID:ManuCutillas,项目名称:javascript-obfuscator,代码行数:25,代码来源:MemberExpressionObfuscator.ts

示例7:

                        }
                    }
                }
            ],
            "kind": "var"
        }
    ],
    "sourceType": "script"
};

estraverse.traverse(ast, {
    enter: (node: any, parentNode: any) => {
        if (node.type === 'Identifier') {
            return estraverse.VisitorOption.Skip;
        }
    },
    leave: (node: any, parentNode: any) => {},
    fallback: 'iteration',
    keys: {
        TestExpression: ['argument']
    }
});

estraverse.replace(ast, {
    enter: (node: any, parentNode: any) => {
        return node;
    },
    leave: (node: any, parentNode: any) => {
        return node;
    }
});
开发者ID:1drop,项目名称:DefinitelyTyped,代码行数:31,代码来源:estraverse-tests.ts

示例8: enter

                    }
                }
            ],
            "kind": "var"
        }
    ],
    "sourceType": "script"
};

estraverse.traverse(ast, {
    enter(node: estree.Node, parentNode: estree.Node | null) {
        if (node.type === 'Identifier') {
            return estraverse.VisitorOption.Skip;
        }
    },
    leave: (node: estree.Node, parentNode: estree.Node | null) => {},
    fallback: 'iteration',
    keys: {
        TestExpression: ['argument']
    }
});

estraverse.replace(ast, {
    enter: (node: estree.Node, parentNode: estree.Node | null) => {
        return node;
    },
    leave: (node: estree.Node, parentNode: estree.Node | null) => {
        return node;
    }
});
开发者ID:AbraaoAlves,项目名称:DefinitelyTyped,代码行数:30,代码来源:estraverse-tests.ts


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