How to use the uglify-js-papandreou.parse 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
get parseTree() {
        if (!this._parseTree) {
            var text = this.text;
            // If the source ends with one or more comment, add an empty statement at the end so there's a token
            // for the UglifyJS parser to attach them to (workaround for https://github.com/mishoo/UglifyJS2/issues/180)
            if (/(?:\/\/[^\r\n]*|\*\/)[\r\s\n]*$/.test(text)) {
                text += '\n;';
            }
            try {
                this._parseTree = uglifyJs.parse(text);
            } catch (e) {
                var err = new errors.ParseError({
                    message: 'Parse error in ' + this.urlOrDescription + '\n' + e.message + ' (line ' + e.line + ', column ' + (e.col + 1) + ')',
                    line: e.line,
                    column: e.col + 1,
                    asset: this
                });
                if (this.assetGraph) {
                    this.assetGraph.emit('warn', err);
                } else {
                    throw err;
                }
                this._parseTree = uglifyJs.parse('');
            }
        }
        return this._parseTree;
github assetgraph / assetgraph / lib / assets / JavaScript.js View on Github external
}
            try {
                this._parseTree = uglifyJs.parse(text);
            } catch (e) {
                var err = new errors.ParseError({
                    message: 'Parse error in ' + this.urlOrDescription + '\n' + e.message + ' (line ' + e.line + ', column ' + (e.col + 1) + ')',
                    line: e.line,
                    column: e.col + 1,
                    asset: this
                });
                if (this.assetGraph) {
                    this.assetGraph.emit('warn', err);
                } else {
                    throw err;
                }
                this._parseTree = uglifyJs.parse('');
            }
        }
        return this._parseTree;
    },