export async function delay ( sec ) { return new Promise ( ( resolve ) => { setTimeout ( resolve , sec * 1000 ) ; } ) ; } export async function timeout < T > ( promise , sec ) { const err = new Error ( 'timeout' ) ; return Promise . race ( [ promise , new Promise < never > ( ( resolve , reject ) => { setTimeout ( ( ) => reject ( err ) , sec * 1000 ) ; } ) , ] ) ; }