Sha256: 5dfeb7c1e61f393df2ea43eebd41de503322204fd0c31eae2d4676e90ceaa9ce

Contents?: true

Size: 1.59 KB

Versions: 14

Compression:

Stored size: 1.59 KB

Contents

// Emulate enough of CommonJS to load unmodified UglifyJS files
var exports = {};
function require() {
    return exports;
}

// Enough compatibility with JavaScript 1.8
// Copied from https://developer.mozilla.org/en/JavaScript/Reference/Global_Objects/Array/Reduce
if(!Array.prototype.reduce) {
    Array.prototype.reduce = function reduce(accumlator){
        var i, l = this.length, curr;
        if(typeof accumlator !== "function") // ES5 : "If IsCallable(callbackfn) is false, throw a TypeError exception."
        throw new TypeError("First argument is not callable");
        if((l == 0 || l === null) && (arguments.length <= 1))// == on purpose to test 0 and false.
        throw new TypeError("Array length is 0 and no second argument");
        if(arguments.length <= 1){
            curr = this[0]; // Increase i to start searching the secondly defined element in the array
            i = 1; // start accumulating at the second element
        } else {
            curr = arguments[1];
        }
        for(i = i || 0 ; i < l ; ++i){
            if(i in this)
            curr = accumlator.call(undefined, curr, this[i], i, this);
        }
        return curr;
    };
}

// Function to call from the Ruby PluginTool::Minimiser#process function
function js_min(orig_code) {
    // usage from https://github.com/mishoo/UglifyJS
    var ast = jsp.parse(orig_code); // parse code and get the initial AST
    ast = exports.ast_mangle(ast); // get a new AST with mangled names
    ast = exports.ast_squeeze(ast); // get an AST with compression optimizations
    return exports.gen_code(ast); // compressed code here    
}

Version data entries

14 entries across 14 versions & 2 rubygems

Version Path
haplo-2.1.0-java lib/js_min.js
oneis-2.0.6-java lib/js_min.js
oneis-2.0.5-java lib/js_min.js
oneis-2.0.4-java lib/js_min.js
oneis-2.0.3-java lib/js_min.js
oneis-2.0.2-java lib/js_min.js
oneis-2.0.1-java lib/js_min.js
oneis-1.2.2-java lib/js_min.js
oneis-1.2.1-java lib/js_min.js
oneis-1.2.0-java lib/js_min.js
oneis-1.1.0-java lib/js_min.js
oneis-1.0.4-java lib/js_min.js
oneis-1.0.1-java lib/js_min.js
oneis-1.0.0-java lib/js_min.js