Write algorithms that can be re-used for synchronous and asynchronous code using promises and `yield`