export function addTimeoutToPromise < T > ( promise , ms ) { return new Promise ( ( resolve , reject ) => { const timeout = setTimeout ( ( ) => { reject ( ) ; } , ms ) ; promise . then ( result => { clearTimeout ( timeout ) ; resolve ( result ) ; } , error => { clearTimeout ( timeout ) ; reject ( error ) ; } ) ; } ) ; } export function isPromiseLike < T > ( obj ) { return typeof obj . then === 'function' ; }