ES 5-6-7: From Callbacks to Promises to Generators to Async/await

This article makes sense — but I can’t translate it into a working test. :(

You said that if I “yield a promise, I’ll get a result back” — but I’m not seeing that in practice.

In a simple node app, I’m doing:

var fs = require(“fs”);
function promiseRead(filename) {
 return new Promise((res, rej) => { 
 fs.readFile(filename, (err, content) => {
 if (!err) res(content);
 else rej(err);
function* readFile(filename) {
 return yield promiseRead(filename);
var content = readFile(“app.js”);

But the result I’m getting is “{}” — certainly not the content of app.js. But if I


I’m getting an unfulfilled promise:

{ value: Promise { <pending> }, done: false }

and if I *don’t* .next(), promiseRead is never called.

Can you explain what it is that I’m not getting here?