build/packer/packer.js
function encodeBlocks($, prefix, blockType, args, block) {
      if (!prefix) prefix = "";
      if (blockType == "function") {
        // decode the function block (THIS IS THE IMPORTANT BIT)
        // We are retrieving all sub-blocks and will re-parse them in light
        // of newly shrunk variables
        block = args + decodeBlocks(block, SCOPED);
        prefix = prefix.replace(BRACKETS, "");
        
        // create the list of variable and argument names
        args = args.slice(1, -1);
        
        if (args != "_no_shrink_") {
          var vars = match(block, VARS).join(";").replace(VAR_g, ";var");
          while (BRACKETS.test(vars)) {
            vars = vars.replace(BRACKETS_g, "");
          }
          vars = vars.replace(VAR_TIDY, "").replace(VAR_EQUAL, "");
        }
        block = decodeBlocks(block, ENCODED_BLOCK);
        
        // process each identifier
        if (args != "_no_shrink_") {
          var count = 0, shortId;
          var ids = match([args, vars], IDENTIFIER);
          var processed = {};
          for (var i = 0; i < ids.length; i++) {
            id = ids[i];
            if (!processed["#" + id]) {
              processed["#" + id] = true;
              id = rescape(id);
              // encode variable names
              while (new RegExp(Shrinker.PREFIX + count + "\\b").test(block)) count++;
              var reg = new RegExp("([^\\w$.])" + id + "([^\\w$:])");
              while (reg.test(block)) {
                block = block.replace(global(reg), "$1" + Shrinker.PREFIX + count + "$2");
              }
              var reg = new RegExp("([^{,\\w$.])" + id + ":", "g");
              block = block.replace(reg, "$1" + Shrinker.PREFIX + count + ":");
              count++;
            }
          }
          total = Math.max(total, count);
        }
        var replacement = prefix + "~" + blocks.length + "~";
        blocks.push(block);
      } else {
        var replacement = "~#" + blocks.length + "~";
        blocks.push(prefix + block);
      }
      return replacement;
    }
function encodeBlocks($, prefix, blockType, args, block) {
      if (!prefix) prefix = "";
      if (blockType == "function") {
        // decode the function block (THIS IS THE IMPORTANT BIT)
        // We are retrieving all sub-blocks and will re-parse them in light
        // of newly shrunk variables
        block = args + decodeBlocks(block, SCOPED);
        prefix = prefix.replace(BRACKETS, "");
        
        // create the list of variable and argument names
        args = args.slice(1, -1);
        
        if (args != "_no_shrink_") {
          var vars = match(block, VARS).join(";").replace(VAR_g, ";var");
          while (BRACKETS.test(vars)) {
            vars = vars.replace(BRACKETS_g, "");
          }
          vars = vars.replace(VAR_TIDY, "").replace(VAR_EQUAL, "");
        }
        block = decodeBlocks(block, ENCODED_BLOCK);
        
        // process each identifier
        if (args != "_no_shrink_") {
          var count = 0, shortId;
          var ids = match([args, vars], IDENTIFIER);
          var processed = {};
          for (var i = 0; i < ids.length; i++) {
            id = ids[i];
            if (!processed["#" + id]) {
              processed["#" + id] = true;
              id = rescape(id);
              // encode variable names
              while (new RegExp(Shrinker.PREFIX + count + "\\b").test(block)) count++;
              var reg = new RegExp("([^\\w$.])" + id + "([^\\w$:])");
              while (reg.test(block)) {
                block = block.replace(global(reg), "$1" + Shrinker.PREFIX + count + "$2");
              }
              var reg = new RegExp("([^{,\\w$.])" + id + ":", "g");
              block = block.replace(reg, "$1" + Shrinker.PREFIX + count + ":");
              count++;
            }
          }
          total = Math.max(total, count);
        }
        var replacement = prefix + "~" + blocks.length + "~";
        blocks.push(block);
      } else {
        var replacement = "~#" + blocks.length + "~";
        blocks.push(prefix + block);
      }
      return replacement;
    }
function encodeBlocks ( $ , prefix , blockType , args , block ) { if ( ! prefix ) prefix = "" ; if ( blockType == "function" ) { // decode the function block (THIS IS THE IMPORTANT BIT) // We are retrieving all sub-blocks and will re-parse them in light // of newly shrunk variables block = args + decodeBlocks ( block , SCOPED ) ; prefix = prefix . replace ( BRACKETS , "" ) ; // create the list of variable and argument names args = args . slice ( 1 , - 1 ) ; if ( args != "_no_shrink_" ) { var vars = match ( block , VARS ) . join ( ";" ) . replace ( VAR_g , ";var" ) ; while ( BRACKETS . test ( vars ) ) { vars = vars . replace ( BRACKETS_g , "" ) ; } vars = vars . replace ( VAR_TIDY , "" ) . replace ( VAR_EQUAL , "" ) ; } block = decodeBlocks ( block , ENCODED_BLOCK ) ; // process each identifier if ( args != "_no_shrink_" ) { var count = 0 , shortId ; var ids = match ( [ args , vars ] , IDENTIFIER ) ; var processed = { } ; for ( var i = 0 ; i < ids . length ; i ++ ) { id = ids [ i ] ; if ( ! processed [ "#" + id ] ) { processed [ "#" + id ] = true ; id = rescape ( id ) ; // encode variable names while ( new RegExp ( Shrinker . PREFIX + count + "\\b" ) . test ( block ) ) count ++ ; var reg = new RegExp ( "([^\\w$.])" + id + "([^\\w$:])" ) ; while ( reg . test ( block ) ) { block = block . replace ( global ( reg ) , "$1" + Shrinker . PREFIX + count + "$2" ) ; } var reg = new RegExp ( "([^{,\\w$.])" + id + ":" , "g" ) ; block = block . replace ( reg , "$1" + Shrinker . PREFIX + count + ":" ) ; count ++ ; } } total = Math . max ( total , count ) ; } var replacement = prefix + "~" + blocks . length + "~" ; blocks . push ( block ) ; } else { var replacement = "~#" + blocks . length + "~" ; blocks . push ( prefix + block ) ; } return replacement ; }
encoder for program blocks
encoder for program blocks