File tree Expand file tree Collapse file tree 1 file changed +7
-0
lines changed
Expand file tree Collapse file tree 1 file changed +7
-0
lines changed Original file line number Diff line number Diff line change @@ -71,6 +71,10 @@ export class EntityFactory<Entity> implements EntityFactoryInterface<Entity> {
7171 private async makeEntity ( entity : Entity ) : Promise < Entity > {
7272 for ( const attribute in entity ) {
7373 if ( entity . hasOwnProperty ( attribute ) ) {
74+ if ( this . isPromiseLike ( entity [ attribute ] ) ) {
75+ entity [ attribute ] = await entity [ attribute ] ;
76+ }
77+
7478 if ( typeof entity [ attribute ] === 'object' && entity [ attribute ] instanceof EntityFactory ) {
7579 const subEntityFactory = entity [ attribute ] ;
7680 const subEntity = await ( subEntityFactory as any ) . build ( ) ;
@@ -81,4 +85,7 @@ export class EntityFactory<Entity> implements EntityFactoryInterface<Entity> {
8185 return entity ;
8286 }
8387
88+ private isPromiseLike ( object : any ) : boolean {
89+ return ! ! object && ( typeof object === 'object' || typeof object === 'function' ) && typeof object . then === 'function' ;
90+ }
8491}
You can’t perform that action at this time.
0 commit comments