Created
October 4, 2011 04:28
-
-
Save sidneylimafilho/1260907 to your computer and use it in GitHub Desktop.
Counterproof node is a cancer
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var http = require("http"); | |
function fibonacci(n, callback) { | |
if (n < 2) return 1; | |
if (callback) | |
setTimeout(function () { callback(fibonacci(n - 2) + fibonacci(n - 1)) }, 0); | |
else | |
return fibonacci(n - 2) + fibonacci(n - 1); | |
} | |
http.createServer(function (req, res) { | |
res.writeHead(200, { 'Content-Type': 'text/plain' }); | |
fibonacci(40, function (r) { res.end(String(r)) }); | |
}).listen(1337, "127.0.0.1"); | |
// | |
// Sample only to prove the non blocking | |
// | |
http.createServer(function (req, res) { | |
res.writeHead(200, { 'Content-Type': 'text/plain' }); | |
res.end("Non Blocking! " + req.query); | |
}).listen(1338, "127.0.0.1"); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment