Skip to content

Async sleep function with typescript support.

License

Notifications You must be signed in to change notification settings

flitrue/ts-sleep

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

3 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

ts-sleep

Async sleep function with typescript support.

Installation

npm install ts-promise -S

Usage

import sleep from 'ts-sleep'

function myFunction() {
  sleep(500).then(res => {
    console.info('It is 500 ms later now')
  })
}

myFunction()

Early suspend promise

import sleep from 'ts-sleep'

function myFunction() {
  let p = sleep(500).then(res => {
    console.info('It is 200 ms later now')
  })

  setTimeout(() => {
    p.cancel()
  }, 200)
}

myFunction()

Debug

npm run build // Run compile

npm run test // Run tests

About

Async sleep function with typescript support.

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published