當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。