ko-timeout
v1.1.6
Published
Error on timeout
Downloads
49
Readme
ko-timeout
deprecated please use https://github.com/sindresorhus/delay
usage
timeout(gen, ms)
gen
- a genarator function
ms
- millisecond. can use '3s' or '200ms', which https://www.npmjs.com/package/ms support
if timeout, err.name
will be CoTimeoutError
example
should timeout
try {
yield timeout(function * () {
yield sleep(50)
}, 20)
} catch (e) {
e.message.should.eql('timeout: exceed 20ms')
}
should get return value
var value = yield timeout(function * () {
yield sleep(10)
return 30;
}, 20)
value.should.eql(30)
license
MIT