Pergunta

So I read this guide a while ago and I stopped using semicolons after every line statement in Javascript.

I want to show my SaaS application to a company hoping for some contract work. Most of the work is done in Javascript and I don't want the company to simply copy my JS code (and figure out the rest). So I wanted to pack it (with Base62 encode).

Here is a sample of my code:

    var options = {
        averageCenter  : true,
        gridSize       : 40,
        maxZoom        : 16,
        imagePath      : 'common/images/m',
        imageExtension : 'png'
    }

    var marker_cluster = new MarkerClusterer( MAP, MARKERS, options )

    marker_cluster.setCalculator
    (
        function( markers, numStyles ) {
            var index = 0
            var count = markers.length.toString()

            if     ( count < 5  ) index = 1
            else if( count < 20 ) index = 2
            else if( count < 40 ) index = 3
            else if( count < 80 ) index = 4
            else                  index = 5

            return {
                text  : count,
                index : index
            }
        }
    )

But Dean Edwards' Packer requires you to end every statement with a semicolon. Do I need to manually go back to insert a semicolon or is there another packer that doesn't require a semicolon, then pack it with Dean Edward's Packer?

Foi útil?

Solução

Closure Compiler doesn't seem to have any issue. However, I would note that neither this nor the Packer are obfuscators. Packer actually has decode functionality built-in, though you need a simple trick to use it.

Even dedicated obfuscation tools are mostly a waste of time. Your code can still be recovered with enough effort.

Finally, I recommend you do use semi-colons. Even that article admits that it caused him a problem several times. I also think the semi-colons do make the return statement problem much more obvious; further, in other languages I do sometimes put a line break there for long returns.

Licenciado em: CC-BY-SA com atribuição
Não afiliado a StackOverflow
scroll top