Skip to content

Instantly share code, notes, and snippets.

@gnbaron
Created July 2, 2021 00:02
Show Gist options
  • Save gnbaron/ce94b2f2d53d8f4a5189062fae6e799e to your computer and use it in GitHub Desktop.
Save gnbaron/ce94b2f2d53d8f4a5189062fae6e799e to your computer and use it in GitHub Desktop.
Flush promises
/**
* A promise that resolves on next tick.
* Beneficial for waiting for immediately resolved promises without
* lengthy promise chains.
*/
export const flushPromises = (): Promise<void> =>
new Promise(resolve => setImmediate(resolve))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment