1 function isPromise (value: any) {
2 return value && typeof value.then === 'function'
5 function isCatchable (value: any) {
6 return value && typeof value.catch === 'function'
9 function timeoutPromise <T> (promise: Promise<T>, timeoutMs: number) {
10 let timer: ReturnType<typeof setTimeout>
15 new Promise((_res, rej) => {
16 timer = setTimeout(() => rej(new Error('Timeout')), timeoutMs)
18 ]).finally(() => clearTimeout(timer))