Promisified Functions Demo

    Promisified setTimeout

    Wait for a specified amount of time

    Result:

    No result yet

    Code Snippet:

    
    const promisifiedSetTimeout = (ms: number): Promise<void> => {
      return new Promise((resolve) => {
        setTimeout(resolve, ms)
      })
    }
    
    // Usage
    try {
      await promisifiedSetTimeout(1000)
      console.log('Waited for 1 second')
    } catch (error) {
      console.error('Error:', error)
    }