@@ -108,10 +108,10 @@ class Handlers {
108108 if ( value . type === "entry" ) {
109109 this . entryActions . push ( value ) ;
110110
111- const result = new Promise ( ( resolve ) => {
111+ const resultPromise = new Promise ( ( resolve ) => {
112112 resolve ( value . f ( ) ) ;
113- } ) ;
114- this . promises . push ( result ) ;
113+ } ) . then ( result => ( { [ value . f . name ] : result } ) ) ;
114+ this . promises . push ( resultPromise ) ;
115115
116116 } else if ( value . type === "exit" ) {
117117 this . exitActions . push ( value ) ;
@@ -122,12 +122,13 @@ class Handlers {
122122 }
123123 }
124124
125- finish ( ) : null | Promise < Array < any > > {
125+ finish ( ) : null | Promise < Record < string , any > > {
126126 if ( this . promises . length === 0 ) return null ;
127127
128128 const promise = Promise . resolve ( this . promise )
129129 . catch ( ( ) => { } )
130- . then ( ( ) => Promise . all ( this . promises ) ) ;
130+ . then ( ( ) => Promise . all ( this . promises ) )
131+ . then ( resultObjects => Object . assign ( { } , ...resultObjects ) ) ;
131132
132133 this . promise = promise ;
133134
@@ -153,7 +154,7 @@ class InternalInstance {
153154 private definition : ( ( ) => StateDefinition ) | ( ( ) => Generator < Yielded , StateDefinition , never > )
154155 private parent : null | InternalInstance
155156 private globalHandlers = new Handlers ( )
156- private resolved = null as Promise < Array < any > > | null
157+ private resolved = null as Promise < Record < string , any > > | null
157158 child : null | InternalInstance = null
158159
159160 constructor (
@@ -194,9 +195,9 @@ class InternalInstance {
194195 return Array . from ( this . generateActions ( ) ) ;
195196 }
196197
197- private async * valuePromises ( ) : AsyncGenerator < any , void , undefined > {
198+ private async * valuePromises ( ) : AsyncGenerator < Record < string , any > , void , undefined > {
198199 if ( this . resolved !== null ) {
199- yield * await this . resolved ;
200+ yield await this . resolved ;
200201 }
201202 if ( this . child !== null ) {
202203 yield * this . child . valuePromises ( ) ;
@@ -205,14 +206,14 @@ class InternalInstance {
205206
206207 get value ( ) : Promise < Array < any > > {
207208 const build = async ( ) => {
208- const values : Array < any > = [ ] ;
209- for await ( const value of this . valuePromises ( ) ) {
210- values . push ( value ) ;
209+ const objects : Array < any > = [ ] ;
210+ for await ( const object of this . valuePromises ( ) ) {
211+ objects . push ( object ) ;
211212 }
212- return values ;
213+ return objects ;
213214 }
214215
215- return build ( ) . then ( values => Promise . all ( values ) ) ;
216+ return build ( ) . then ( objects => Object . assign ( { } , ... objects ) ) ;
216217 }
217218
218219 consume ( stateGenerator : ( ( ) => StateDefinition ) | ( ( ) => Generator < Yielded , StateDefinition , never > ) ) {
0 commit comments