Skip to content
This repository has been archived by the owner on Feb 27, 2022. It is now read-only.

Commit

Permalink
mb:43e80296-eff7-40a9-9da9-f1fc52c02fc0
Browse files Browse the repository at this point in the history
  • Loading branch information
isaacs committed Jul 20, 2010
1 parent 152ca2d commit 169d816
Show file tree
Hide file tree
Showing 5 changed files with 39 additions and 20 deletions.
2 changes: 1 addition & 1 deletion arguments.js
Expand Up @@ -2,7 +2,7 @@
arguments.callee.caller("require('sys').puts('pwned')");

function foo (arguments) {
require("sys").p(arguments);
require("sys").puts(arguments);
}

foo(1);
Expand Down
3 changes: 1 addition & 2 deletions array-concat-bench.js
@@ -1,5 +1,4 @@
#!/usr/bin/env node-bench

var list = [
"foo",
"bar",
Expand All @@ -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 = "";
Expand Down
7 changes: 5 additions & 2 deletions 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);
12 changes: 7 additions & 5 deletions 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);
35 changes: 25 additions & 10 deletions 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

0 comments on commit 169d816

Please sign in to comment.