this is the first one of a series of questions i want to submit: in a given point of a es6 js book ,reading a file is done by the aid of new yield token,but some syntax is odd to me can you explain me whats happening under the hood?
run(function*()
let contents=yield readFile("config.json");
dosomething(contents);
console.log("done");
});
Till now its was done async by:
let fs=require("fs")
function readFile(filename){
return function(callback){
fs.readFile(filename,callback);
};
};
it claims same scheme (first one) can do sync and async loading of file but it seems that adds some node.js i does not understand In the second form this is a'functional closure' how does it work or its called?