lib/transform.js
function(line) {
        //^
        // (\s*)        $1 opts leading spaces
        // ([\w$]+\s*)  $2 variable name & trailing spaces
        // (\=)         $3 division equals OR
        // \s*          opt spaces
        // (.*?)        rest of expression to assign
        // $
        var parts = line.match(/^(\s*)([\w$]+)\s*(\=)\s*(.*?)$/);
        if (!parts) return line;

        var leadingSpace = parts[1];
        var name = parts[2].trim();
        var operator = parts[3].trim();
        var rest = parts[4];

        return leadingSpace + 'const ' + name + ' ' + operator + ' ' + rest;
    }
function(line) {
        //^
        // (\s*)        $1 opts leading spaces
        // ([\w$]+\s*)  $2 variable name & trailing spaces
        // (\=)         $3 division equals OR
        // \s*          opt spaces
        // (.*?)        rest of expression to assign
        // $
        var parts = line.match(/^(\s*)([\w$]+)\s*(\=)\s*(.*?)$/);
        if (!parts) return line;

        var leadingSpace = parts[1];
        var name = parts[2].trim();
        var operator = parts[3].trim();
        var rest = parts[4];

        return leadingSpace + 'const ' + name + ' ' + operator + ' ' + rest;
    }
function ( line ) { //^ // (\s*)        $1 opts leading spaces // ([\w$]+\s*)  $2 variable name & trailing spaces // (\=)         $3 division equals OR // \s*          opt spaces // (.*?)        rest of expression to assign // $ var parts = line . match ( / ^(\s*)([\w$]+)\s*(\=)\s*(.*?)$ / ) ; if ( ! parts ) return line ; var leadingSpace = parts [ 1 ] ; var name = parts [ 2 ] . trim ( ) ; var operator = parts [ 3 ] . trim ( ) ; var rest = parts [ 4 ] ; return leadingSpace + 'const ' + name + ' ' + operator + ' ' + rest ; }
adds `const` to any declaration, works with shorthand operators String a -> String b
adds const to any declaration works with shorthand operators String a - > String b