proto-timeout
v1.0.1
Published
Adds timeouts to promises
Downloads
4
Readme
by @DecentM
Adds a convenient timeout function to your promises
Usage
const install = require('proto-timeout')
install()
const get = () => new Promise((resolve, reject) => {
setTimeout(() => {
resolve('Hello, world!')
}, 100)
})
get()
.timeout(200)
.then((result) => {
console.log(result)
})
Exported functions
(main)
: Theninstall
functiontimeout
: The addedtimeout
function, requires apromise
variable in scopeuninstall
: Undoes the actions of theinstall
function