目录 · 5 个章节
https://github.com/alsotang/ko-timeout
ko-timeout
usage
timeout(gen, ms)
gen - a genarator function
ms - millisecond. can use '3s' or '200ms', which https://www.npmjs.com/package/ms support
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