Joined May 2011
·

Jonathan Fielding

Senior Web Developer at McCormack & Morrison
·
London
·
·
·

Posted to Simple Node.js prompt over 1 year ago

I really liked your method, but I am using promises so I edited it slightly, this is my edited version that uses q library for promises

var ask = function(question) {
    var deferred = q.defer();

var r = rl.createInterface({
    input: process.stdin,
    output: process.stdout
});

r.question(question + '\n', function(answer) {
    r.close();
    deferred.resolve(answer);
});


return deferred.promise;
};</code></pre>
Achievements
89 Karma
0 Total ProTip Views