export function wait ( timeInMs ) { let timeoutHandle ; return { promise : new Promise < void > ( function ( resolve ) { timeoutHandle = setTimeout ( resolve , timeInMs ) ; } ) , cancel : ( ) => clearTimeout ( timeoutHandle ) , } ; }