How to use the uglify-js-papandreou.AST_Block function in uglify-js-papandreou

To help you get started, we’ve selected a few uglify-js-papandreou examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github assetgraph / assetgraph / lib / assets / JavaScript.js View on Github external
node.args[0] instanceof uglifyJs.AST_Array) {
                    // There's no 3 argument version of require, so check whether the require is succeeded by define('moduleName', ...);
                    // like flattenRequireJs and r.js would output. If it is, don't model it as a relation.
                    var parentIndex = stack.length - 1,
                        isSucceededByDefineWithStringArg = false,
                        seenDefine = false,
                        walkFn = function (_node) {
                            if (_node === node) {
                                seenDefine = true;
                            } else if (seenDefine && isNamedDefineNode(_node)) {
                                isSucceededByDefineWithStringArg = true;
                            }
                        };
                    OUTER:
                    while (parentIndex >= 0) {
                        if (stack[parentIndex] instanceof uglifyJs.AST_Block) {
                            var blockNode = stack[parentIndex];
                            for (var i = blockNode.body.indexOf(stack[parentIndex + 1]) ; i < blockNode.body.length ; i += 1) {
                                if (blockNode.body[i] instanceof uglifyJs.AST_SimpleStatement && isNamedDefineNode(blockNode.body[i].body)) {
                                    isSucceededByDefineWithStringArg = true;
                                    break OUTER;
                                }
                            }
                            break OUTER;
                        } else if (stack[parentIndex] instanceof uglifyJs.AST_Seq) {
                            stack[parentIndex].walk(new uglifyJs.TreeWalker(walkFn));
                            break OUTER;
                        } else {
                            parentIndex -= 1;
                        }
                    }