@@ -28,7 +28,7 @@ exports.run_code = semver.satisfies(process.version, "0.8") ? function(code, top
2828 if ( [
2929 / \b a s y n c [ \t ] * \( [ \s \S ] * ?\) [ \t ] * = > / ,
3030 / \b ( a s y n c [ \t ] + f u n c t i o n | P r o m i s e | s e t I m m e d i a t e | s e t I n t e r v a l | s e t T i m e o u t ) \b / ,
31- / \b a s y n c ( [ \t ] + | [ \t ] * # | [ \t ] * \* [ \t ] * ) [ ^ \s ( ) [ \] { } , . & | ! ~ = * % / + - ] + ( \s * \( | [ \t ] * = > ) / ,
31+ / \b a s y n c ( [ \t ] + | [ \t ] * # | [ \t ] * \* [ \t ] * ) [ ^ \s ( ) [ \] { } # , . & | ! ~ = * % / + - ] + ( \s * \( | [ \t ] * = > ) / ,
3232 ] . some ( function ( pattern ) {
3333 return pattern . test ( code ) ;
3434 } ) ) {
@@ -51,13 +51,13 @@ exports.same_stdout = semver.satisfies(process.version, "0.12") ? function(expec
5151} ;
5252exports . patch_module_statements = function ( code ) {
5353 var count = 0 , imports = [ ] ;
54- code = code . replace ( / \b e x p o r t (?: \s * \{ [ ^ } ] * } \s * ?(?: $ | \n | ; ) | \s + d e f a u l t \b (?: \s * ( \( | \{ | c l a s s \s * \{ | c l a s s \s + (? = e x t e n d s \b ) | (?: a s y n c \s + ) ? f u n c t i o n \s * (?: \* \s * ) ? \( ) ) ? | \b ) / g, function ( match , header ) {
54+ code = code . replace ( / \b e x p o r t (?: \s * \{ [ ^ { } ] * } \s * ?(?: $ | \n | ; ) | \s + d e f a u l t \b (?: \s * ( \( | \{ | c l a s s \s * \{ | c l a s s \s + (? = e x t e n d s \b ) | (?: a s y n c \s + ) ? f u n c t i o n \s * (?: \* \s * ) ? \( ) ) ? | \b ) / g, function ( match , header ) {
5555 if ( ! header ) return "" ;
5656 if ( header . length == 1 ) return "0, " + header ;
5757 return header . slice ( 0 , - 1 ) + " _" + ++ count + header . slice ( - 1 ) ;
5858 } ) . replace ( / \b i m p o r t \. m e t a \b / g, function ( ) {
5959 return '({ url: "https://example.com/path/index.html" })' ;
60- } ) . replace ( / \b i m p o r t \b (?: \s * ( [ ^ ( ' " ] + ) \b f r o m \b ) ? \s * ( [ ' " ] ) .* ?\2(?: $ | \n | ; ) / g, function ( match , symbols ) {
60+ } ) . replace ( / \b i m p o r t \b (?: \s * ( [ ^ \s ( ' " ] [ ^ ( ' " ] * ) \b f r o m \b ) ? \s * ( [ ' " ] ) .* ?\2(?: $ | \n | ; ) / g, function ( match , symbols ) {
6161 if ( symbols ) {
6262 if ( ! / ^ [ { * ] / . test ( symbols ) ) symbols = "default:" + symbols ;
6363 symbols = symbols . replace ( / [ { } ] / g, "" ) . trim ( ) . replace ( / \s * , \s * / g, "," ) ;
0 commit comments