How to use the uglify-js-papandreou.TreeTransformer 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
function isNamedDefineNode(node) {
    return (
        node instanceof uglifyJs.AST_Call &&
        node.expression instanceof uglifyJs.AST_Symbol &&
        node.expression.name === 'define' &&
        node.args.length === 2 &&
        node.args[0] instanceof uglifyJs.AST_String
    );
}

function shouldCommentNodeBePreservedInNonPrettyPrintedOutput(node, comment) {
    return (/@preserve|@license|@cc_on|[@#]\s*sourceURL|[#@]\s*sourceMappingURL|^!/).test(comment.value);
}

// From http://lisperator.net/uglifyjs/transform
var deepCloneTransform = new uglifyJs.TreeTransformer(function (node, descend) {
    node = node.clone();
    // the descend function expects two arguments:
    // the node to dive into, and the tree walker
    // `this` here is the tree walker (=== deep_clone).
    // by descending into the *cloned* node, we keep the original intact
    descend(node, this);
    return node;
});

extendWithGettersAndSetters(JavaScript.prototype, {
    contentType: 'application/javascript', // TODO: Double check that this is everyone's recommended value

    supportedExtensions: ['.js'],

    isPretty: false,