File tree Expand file tree Collapse file tree 1 file changed +11
-13
lines changed Expand file tree Collapse file tree 1 file changed +11
-13
lines changed Original file line number Diff line number Diff line change @@ -65,23 +65,21 @@ export class ProgressIndicator {
6565 }
6666}
6767
68- export function withProgress < T > (
68+ export async function withProgress < T > (
6969 message : string ,
7070 operation : ( progress : ProgressIndicator ) => Promise < T >
7171) : Promise < T > {
72- return new Promise ( async ( resolve , reject ) => {
73- const progress = new ProgressIndicator ( message ) ;
74- progress . start ( ) ;
72+ const progress = new ProgressIndicator ( message ) ;
73+ progress . start ( ) ;
7574
76- try {
77- const result = await operation ( progress ) ;
78- progress . succeed ( ) ;
79- resolve ( result ) ;
80- } catch ( error ) {
81- progress . fail ( ) ;
82- reject ( error ) ;
83- }
84- } ) ;
75+ try {
76+ const result = await operation ( progress ) ;
77+ progress . succeed ( ) ;
78+ return result ;
79+ } catch ( error ) {
80+ progress . fail ( ) ;
81+ throw error ;
82+ }
8583}
8684
8785export const progressFrames = {
You can’t perform that action at this time.
0 commit comments