Skip to content

Instantly share code, notes, and snippets.

@aredridel
Last active August 29, 2015 14:11
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save aredridel/97a979e343d3984e4562 to your computer and use it in GitHub Desktop.
Save aredridel/97a979e343d3984e4562 to your computer and use it in GitHub Desktop.
Refactoring to continuation-passing
var http = require('http');
var bl = require('bl');
function start(callback) {
option = {};
options.path = '/start';
var req = http.request(options, function (res) { res.pipe(bl(callback)) });
req.end();
}
start(function (err, startingRoomId) {
if (err) {
console.warn(err);
} else {
console.log(startingRoomId.toString());
}
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment