I am using the promise library bluebird
with node 0.11.9
running with the flag --harmony
I have a simple working example:
var Promise = require('bluebird');
var fs = require('fs');
var readdirAsync = Promise.promisify(fs.readdir, fs);
var statAsync = Promise.promisify(fs.stat, fs);
Promise.spawn(function *() {
var files = yield readdirAsync('./');
var stats = yield files.map(function(file) { return statAsync(file); });
console.log(stats);
console.log('done');
});
This works fine and output the list of nodes' stats. But with the following version: there is no output at all:
var Promise = require('bluebird');
var fs = require('fs');
var readdirAsync = Promise.promisify(fs.readdir, fs);
var statAsync = Promise.promisify(fs.stat, fs);
Promise.spawn(function *() {
var files = yield readdirAsync('./');
var stats = yield files.map(statAsync);
console.log(stats);
console.log('done');
});
Any idea of why this doesn't work ?