export async function sleep(ms: number): Promise<void> {
  await new Promise<void>(resolve => setTimeout(resolve, ms))
}

export async function yieldToEventLoop(): Promise<void> {
  await new Promise<void>((resolve) => {
    const si = (globalThis as any).setImmediate
    if (typeof si === 'function')
      return si(resolve)
    setTimeout(resolve, 0)
  })
}
