Comment

Comment by eloff

You can also do this with a wrapper around setTimeout, if you're in an older environment:

  /\*
   \* A sleep function that returns a promise.
   \*
   \* @example
   \* Sleep for 100ms
   \* ```
   \* await wait(100);
   \* ```
   \*/
  export async function wait(ms: number) {
      return new Promise(resolve => {
          setTimeout(resolve, ms);
      });
  }
parent eloff 5 years ago

Discussion

Live from the official Hacker News API

A modern reader for Hacker News · SvelteKit + Skeleton