JSDOC/CompressWhite.js
authoralan <alan@alanfast.akbkhome.com>
Mon, 19 Apr 2010 04:52:23 +0000 (12:52 +0800)
committeralan <alan@alanfast.akbkhome.com>
Mon, 19 Apr 2010 04:52:23 +0000 (12:52 +0800)
JSDOC/CompressWhite.js

index 22b99e6..eba5957 100644 (file)
@@ -4,9 +4,11 @@
  * pack a javascript file, and return a shorter version!
  * 
  * a bit picky at present with ; and crlf reading...
- * 
+ * @arg ts {TokenStream} 
+   @arg packer {Packer} 
  */
-JSDOC.CompressWhite =  function (ts, packer)
+CompressWhite =  function (ts, packer)
 {
     
     ts.rewind();
@@ -18,7 +20,7 @@ JSDOC.CompressWhite =  function (ts, packer)
         if (!tok) {
             break;
         }
-        if (tok._isWS) {
+        if (tok.type == "WHIT") {
             continue;
             //if (tok._isDoc) {
             //    continue;
@@ -32,11 +34,11 @@ JSDOC.CompressWhite =  function (ts, packer)
         }
         
         // add semi-colon's where linebreaks are used... - not foolproof yet.!
-        if (tok.isTypeN(Script.TOKidentifier)) {
+        if (tok.type == "NAME")) {
             //var tokident = ts.look(-1).data + tok.data + ts.look(1).data +  ts.look(2).data;
             // a = new function() {} 
-            if (ts.look(1).isTypeN(Script.TOKassign) && ts.look(2).isTypeN(Script.TOKnew) && 
-                ts.look(3).isTypeN(Script.TOKfunction)) {
+            if (ts.lookTok(1).data == '=' && ts.lookTok(2).name == 'NEW'  && 
+                ts.look(3).name == 'FUNCTION') {
                 // freeze time.. 
                 var cu = ts.cursor;