diff --git a/arguments.js b/arguments.js index b71e59d..bcb32ed 100644 --- a/arguments.js +++ b/arguments.js @@ -2,7 +2,7 @@ arguments.callee.caller("require('sys').puts('pwned')"); function foo (arguments) { - require("sys").p(arguments); + require("sys").puts(arguments); } foo(1); diff --git a/array-concat-bench.js b/array-concat-bench.js index 55aaba6..d8083ee 100755 --- a/array-concat-bench.js +++ b/array-concat-bench.js @@ -1,5 +1,4 @@ #!/usr/bin/env node-bench - var list = [ "foo", "bar", @@ -18,7 +17,7 @@ exports.compare = { var str = list.join(""); }, concat : function () { - var str = ("").concat(list); + var str = String.prototype.concat.apply("", list); }, strplus : function () { var str = ""; diff --git a/http-header-overflow/server.js b/http-header-overflow/server.js index 9b5554b..5cd105b 100644 --- a/http-header-overflow/server.js +++ b/http-header-overflow/server.js @@ -1,7 +1,10 @@ var sys = require("sys"); -require("http").createServer(function (_,res) { - sys.debug("connect"); +require("http").createServer(function (req,res) { + sys.debug("from http server: connect"); res.sendHeader(200, {}); res.sendBody("hi"); + for (var i in req.headers) { + res.sendBody("\nHEADER "+i+": "+req.headers[i]+"\n"); + } res.finish(); }).listen(8000); \ No newline at end of file diff --git a/kriskowals-gist/c.js b/kriskowals-gist/c.js index dc32a18..2149631 100644 --- a/kriskowals-gist/c.js +++ b/kriskowals-gist/c.js @@ -1,19 +1,21 @@ var sys = require("sys"); function d (m, o) { - sys.debug("\n----\n"+m + ": " + JSON.stringify(o, null, 2)+"\n----\n"); + sys.debug(m); + return; + sys.debug("\n----\n"+m + ": " + sys.inspect(o)+"\n----\n"); } // d("before",module); -module.setExports("this is ok"); +module.exports = ("this is ok"); require("./b"); -// d("after",module); +d("after",module); try { - module.setExports("but this isn't"); + module.exports = ("but this isn't"); } catch (ex) { sys.debug("got an error trying to setExport: "+ex.message); } -// d("done",module); +d("done",module); diff --git a/promise-async.js b/promise-async.js index a32f5a9..6983c99 100644 --- a/promise-async.js +++ b/promise-async.js @@ -1,25 +1,40 @@ +require("url"); var Promise = require("events").Promise, sys = require("sys"); Promise.prototype.test = function (fn) { - return this.addCallback(function () { process.nextTick(fn) }); + return this.addCallback(fn); }; function foo () { + require("url"); var p = new Promise(); process.nextTick(function () { p.emitSuccess() }); return p; }; -sys.debug("start"); -foo().test(function () { - sys.debug("cb 1"); +sys.puts("1"); +foo().addCallback(function () { + sys.puts("callback 1") }); -sys.debug("after attach 1"); -foo().test(function () { - sys.debug("cb 2"); +sys.puts("2"); +foo().addCallback(function () { + sys.puts("callback 2") +}); +sys.puts("3"); +foo().addCallback(function () { + sys.puts("callback 3") +}); +sys.puts("4"); +foo().addCallback(function () { + sys.puts("callback 4") +}); +sys.puts("5"); +foo().addCallback(function () { + sys.puts("callback 5") +}); +sys.puts("6"); +foo().addCallback(function () { + sys.puts("callback 6") }); -sys.debug("after attach 2"); - -// expect start, after attach 1, after attach 2, cb 1, cb 2