export const asyncTimeout = async ( fn , ms ) => { await sleep ( ms ) ; return fn ( ) ; } ; export const sleep = async ( ms ) => new Promise ( ( resolve ) => setTimeout ( resolve , ms ) ) ; export const asyncWrap = async < T > ( promise ) : Promise < [ Error , T ] > => { try { const result = await promise ; return [ null , result ] ; } catch ( e ) { return [ e , null ] ; } } ; export const asyncNextTick = < T > ( promise ) => new Promise < T > ( ( resolve ) => process . nextTick ( async ( ) => resolve ( await promise ) ) ) ;