File tree Expand file tree Collapse file tree 1 file changed +28
-12
lines changed Expand file tree Collapse file tree 1 file changed +28
-12
lines changed Original file line number Diff line number Diff line change @@ -435,18 +435,34 @@ function Plugin(babel) {
435435 } ,
436436 // Transforms a ReturnStatement into an Instruction Token
437437 exit : function ( path ) {
438- if ( path . node . argument === null ) path . node . argument = hzReturn ( ) ;
439- else path . node . argument = hzReturnArg ( path . node . argument ) ;
440- if ( path . getFunctionParent ( ) . node . generator ) path . node . argument . arguments = [ t . ObjectExpression ( [
441- t . ObjectProperty (
442- t . identifier ( "value" ) ,
443- path . node . argument . arguments [ 0 ]
444- ) ,
445- t . ObjectProperty (
446- t . identifier ( "done" ) ,
447- t . BooleanLiteral ( true )
448- )
449- ] ) ] ;
438+ if ( path . getFunctionParent ( ) . node . generator ) {
439+ if ( path . node . argument === null ) {
440+ path . node . argument = hzReturnArg ( t . ObjectExpression ( [
441+ t . ObjectProperty (
442+ t . identifier ( "value" ) ,
443+ t . identifier ( "undefined" )
444+ ) ,
445+ t . ObjectProperty (
446+ t . identifier ( "done" ) ,
447+ t . BooleanLiteral ( true )
448+ )
449+ ] ) ) ;
450+ } else {
451+ path . node . argument = hzReturnArg ( t . ObjectExpression ( [
452+ t . ObjectProperty (
453+ t . identifier ( "value" ) ,
454+ path . node . argument . arguments [ 0 ]
455+ ) ,
456+ t . ObjectProperty (
457+ t . identifier ( "done" ) ,
458+ t . BooleanLiteral ( true )
459+ )
460+ ] ) ) ;
461+ }
462+ } else {
463+ if ( path . node . argument === null ) path . node . argument = hzReturn ( ) ;
464+ else path . node . argument = hzReturnArg ( path . node . argument ) ;
465+ }
450466 }
451467 } ,
452468 "BlockStatement" : {
You can’t perform that action at this time.
0 commit comments