~ubuntu-branches/ubuntu/vivid/emscripten/vivid

« back to all changes in this revision

Viewing changes to tools/eliminator/node_modules/uglify-js/test/beautify.js

  • Committer: Package Import Robot
  • Author(s): Sylvestre Ledru
  • Date: 2013-05-02 13:11:51 UTC
  • Revision ID: package-import@ubuntu.com-20130502131151-q8dvteqr1ef2x7xz
Tags: upstream-1.4.1~20130504~adb56cb
ImportĀ upstreamĀ versionĀ 1.4.1~20130504~adb56cb

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
#! /usr/bin/env node
 
2
 
 
3
global.sys = require("sys");
 
4
var fs = require("fs");
 
5
 
 
6
var jsp = require("../lib/parse-js");
 
7
var pro = require("../lib/process");
 
8
 
 
9
var filename = process.argv[2];
 
10
fs.readFile(filename, "utf8", function(err, text){
 
11
        try {
 
12
                var ast = time_it("parse", function(){ return jsp.parse(text); });
 
13
                ast = time_it("mangle", function(){ return pro.ast_mangle(ast); });
 
14
                ast = time_it("squeeze", function(){ return pro.ast_squeeze(ast); });
 
15
                var gen = time_it("generate", function(){ return pro.gen_code(ast, false); });
 
16
                sys.puts(gen);
 
17
        } catch(ex) {
 
18
                sys.debug(ex.stack);
 
19
                sys.debug(sys.inspect(ex));
 
20
                sys.debug(JSON.stringify(ex));
 
21
        }
 
22
});
 
23
 
 
24
function time_it(name, cont) {
 
25
        var t1 = new Date().getTime();
 
26
        try { return cont(); }
 
27
        finally { sys.debug("// " + name + ": " + ((new Date().getTime() - t1) / 1000).toFixed(3) + " sec."); }
 
28
};