(method, result)
| 21 | return fn(message, (done) => { |
| 22 | const iterator = runnable(); |
| 23 | function step(method, result) { |
| 24 | let state; |
| 25 | try { |
| 26 | state = iterator[method](result); |
| 27 | } catch (e) { |
| 28 | // catch any assertion errors and pass to `done` |
| 29 | // otherwise the messages are swallowed |
| 30 | return done(e); |
| 31 | } |
| 32 | if (state.done) { |
| 33 | Promise.resolve(state.value).then(() => done(), done); |
| 34 | return; |
| 35 | } |
| 36 | |
| 37 | Promise.resolve(state.value).then(_next, _throw); |
| 38 | } |
| 39 | |
| 40 | function _next(value) { |
| 41 | step('next', value); |