Using ES6 generator functions to replace promise and callback-based code