src/usertiming-compression.js
function encode(s) {
            if (!/[^\w-.]/.test(s)) {
                // if the string is only made up of alpha-numeric, underscore,
                // dash or period, we can use it directly.
                return s;
            }

            // we need to escape other characters
            s = s.replace(/[^\w-.]/g, function(ch) {
                if (ch === "$") {
                    return "!";
                }

                // use the character code for this one
                ch = ch.charCodeAt(0);

                if (ch < 0x100) {
                    // if less than 256, use "*[2-char code]"
                    return "*" + ("00" + ch.toString(16)).slice(-2);
                } else {
                    // use "**[4-char code]"
                    return "**" + ("0000" + ch.toString(16)).slice(-4);
                }
            });

            return s;
        }
function encode(s) {
            if (!/[^\w-.]/.test(s)) {
                // if the string is only made up of alpha-numeric, underscore,
                // dash or period, we can use it directly.
                return s;
            }

            // we need to escape other characters
            s = s.replace(/[^\w-.]/g, function(ch) {
                if (ch === "$") {
                    return "!";
                }

                // use the character code for this one
                ch = ch.charCodeAt(0);

                if (ch < 0x100) {
                    // if less than 256, use "*[2-char code]"
                    return "*" + ("00" + ch.toString(16)).slice(-2);
                } else {
                    // use "**[4-char code]"
                    return "**" + ("0000" + ch.toString(16)).slice(-4);
                }
            });

            return s;
        }
function encode ( s ) { if ( ! / [^\w-.] / . test ( s ) ) { // if the string is only made up of alpha-numeric, underscore,
 // dash or period, we can use it directly.
 return s ; } // we need to escape other characters
 s = s . replace ( / [^\w-.] / g , function ( ch ) { if ( ch === "$" ) { return "!" ; } // use the character code for this one
 ch = ch . charCodeAt ( 0 ) ; if ( ch < 0x100 ) { // if less than 256, use "*[2-char code]"
 return "*" + ( "00" + ch . toString ( 16 ) ) . slice ( - 2 ) ; } else { // use "**[4-char code]"
 return "**" + ( "0000" + ch . toString ( 16 ) ) . slice ( - 4 ) ; } } ) ; return s ; }
Encodes the specified string

@param {string} s String

@returns {string} Encoded string
Encodes the specified string