export function useMinDuration ( minDuration ) { let startTimestamp ; return ( promise ) => { startTimestamp = Date . now ( ) ; return new Promise ( ( resolve ) => { promise . then ( ( result ) => { const promiseDuration = Date . now ( ) - startTimestamp ; if ( promiseDuration > minDuration ) { return resolve ( result ) ; } setTimeout ( ( ) => { resolve ( result ) ; } , minDuration - promiseDuration ) ; } ) ; } ) ; } ; }