Skip to content

Instantly share code, notes, and snippets.

What would you like to do?
Total.js Generators and Promisies
const Fs = require('fs');
async(function*() {
var a = yield readFile('');
var b = yield readFile('');
var c = yield readFile('');
// var a = yield sync(Fs.readFile)('');
// var b = yield sync(Fs.readFile)('');
// var c = yield sync(Fs.readFile)('');
console.log('----', a);
console.log('----', b);
console.log('----', c);
function readFile(path) {
return new Promise(function(resolve, reject) {
Fs.readFile(path, function (err, data) {
if (err) reject(err);
else resolve(data.toString());
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.