lib/transform.js
function(line) {
        // example: def bar(a, b) do
        //
        // (^\s*)         begining of line
        // (def|defp)   $1 public or private def
        // (.*?)        $2 in betweend def ... do
        // \s*          optional space
        // do           opening keyword (bracket in JS)
        // \s*$         end of line
        var parts = line.match(/^(\s*)(defp\s|def\s)(.*?)\s*do\s*$/);
        if (!parts) return line;

        // ^(                $1
        // \s*[\w$]+         function name
        // )
        // (                 $2 optional params including parens
        //   \(              literal parens
        //     (.*?)         $3 just params
        //   \)              literal parens
        // )?
        // \s*$              trailing space
        var middle = /^(\s*[\w$]+)(\((.*?)\))?\s*$/;

        var leading = parts[1];
        var funcName = parts[3].trim().match(middle)[1];
        var params = parts[3].trim().match(middle)[3] || '';
        var _export = (parts[2].trim() === 'def') ? 'export ' : '';

        return leading + _export + 'function ' + funcName + '('+ params +') {';
    }
function(line) {
        // example: def bar(a, b) do
        //
        // (^\s*)         begining of line
        // (def|defp)   $1 public or private def
        // (.*?)        $2 in betweend def ... do
        // \s*          optional space
        // do           opening keyword (bracket in JS)
        // \s*$         end of line
        var parts = line.match(/^(\s*)(defp\s|def\s)(.*?)\s*do\s*$/);
        if (!parts) return line;

        // ^(                $1
        // \s*[\w$]+         function name
        // )
        // (                 $2 optional params including parens
        //   \(              literal parens
        //     (.*?)         $3 just params
        //   \)              literal parens
        // )?
        // \s*$              trailing space
        var middle = /^(\s*[\w$]+)(\((.*?)\))?\s*$/;

        var leading = parts[1];
        var funcName = parts[3].trim().match(middle)[1];
        var params = parts[3].trim().match(middle)[3] || '';
        var _export = (parts[2].trim() === 'def') ? 'export ' : '';

        return leading + _export + 'function ' + funcName + '('+ params +') {';
    }
function ( line ) { // example: def bar(a, b) do // // (^\s*)         begining of line // (def|defp)   $1 public or private def // (.*?)        $2 in betweend def ... do // \s*          optional space // do           opening keyword (bracket in JS) // \s*$         end of line var parts = line . match ( / ^(\s*)(defp\s|def\s)(.*?)\s*do\s*$ / ) ; if ( ! parts ) return line ; // ^(                $1 // \s*[\w$]+         function name // ) // (                 $2 optional params including parens //   \(              literal parens //     (.*?)         $3 just params //   \)              literal parens // )? // \s*$              trailing space var middle = / ^(\s*[\w$]+)(\((.*?)\))?\s*$ / ; var leading = parts [ 1 ] ; var funcName = parts [ 3 ] . trim ( ) . match ( middle ) [ 1 ] ; var params = parts [ 3 ] . trim ( ) . match ( middle ) [ 3 ] || '' ; var _export = ( parts [ 2 ] . trim ( ) === 'def' ) ? 'export ' : '' ; return leading + _export + 'function ' + funcName + '(' + params + ') {' ; }
defines public and private module functions returns String a -> String b
defines public and private module functions returns String a - > String b