Implement a wait sync with a promise in TypeScript

Delay a sync execution code


Jul 30, 2021
featured image
      
  waitMs = async (millis: number) => new Promise((resolve) => setTimeout(resolve, millis));

  waitSeconds = async (seconds: number) => new Promise((resolve) => setTimeout(resolve, 1000 * seconds));
      
    
      
await waitMs(10000);

await waitSeconds(10);


    

Photo by Kai Pilger on Unsplash


typescript javascript