I just discovered this project after I made my own implementation of a Javascript compiler into "six characters". It's interesting to compare our implementations, which are quite close actually.
The main difference is for the encode script. Here is mine :
app.encode = function(input){
var charcodes = [];
for(var c=0; c<input.length; c++){
charcodes.push( app.convertInt( input.charCodeAt(c) ) );
}
var out = "[]+" + charcodes.join("+"+app.convertTable["f"]+"+");
out = "[]+(" + out + ")["+_("split")+"]("+app.convertTable["f"]+")";
out = _("return ") + "+" + app.convertTable["String"] + "+" + _(".fromCharCode(") + "+(" + out +")+" + _(')');
out = app.eval(out);
out = app.eval(out);
return out;
};
So i just convert all the input into charCodes and then interprate them with String.fromCharCode(c1,c2,c3,c4...)
For small scripts, your encoder makes file size smaller, but the performance and the script size is far better for large scripts with my approach.
Hi there,
I just discovered this project after I made my own implementation of a Javascript compiler into "six characters". It's interesting to compare our implementations, which are quite close actually.
The main difference is for the encode script. Here is mine :
So i just convert all the input into charCodes and then interprate them with String.fromCharCode(c1,c2,c3,c4...)
For small scripts, your encoder makes file size smaller, but the performance and the script size is far better for large scripts with my approach.
Here is my version: http://syllab.fr/projets/experiments/sixcharsjs/ and the source : http://syllab.fr/projets/experiments/sixcharsjs/js/main.js
Unfortunately I wrote all the explainations in French.