Skip to content

Instantly share code, notes, and snippets.

View isaacs's full-sized avatar
🔮
only way out is through

isaacs isaacs

🔮
only way out is through
View GitHub Profile
(function () {
// exports will be set in any commonjs platform.
// because the anonymous function is being called without
// a scope being set, "this" will refer to the global scope.
// In a browser, that's the window. In other JS platforms,
// it may be some other thing.
var out = typeof exports !== "undefined" ? exports : this;
var sys = require("sys");
function someFunc () {
throw "thrown from someFunc"
};
function h1 (m) {
sys.debug("caught in h1: "+m);
}
function h2 (m) {
var Promise = require("events").Promise,
sys = require("sys");
Promise.prototype.test = function (fn) {
return this.addCallback(fn);
};
function foo () {
var p = new Promise();
// these are all the same.
require("http").createServer(function (req,res) {
res.sendHeader(200, {
"set-cookie" : [ "foo=bar", "bar=baz" ],
"x" : ["y", "z"],
"y" : ["a", "b"]
});
res.finish();
}).listen(8000, "localhost");
We couldn’t find that file to show.
#!/usr/bin/env node-bench
var list = [
"foo",
"bar",
"baz",
"quux",
"asdf",
"qwerty",
diff --git a/deps/v8/tools/linux-tick-processor b/deps/v8/tools/linux-tick-processor
old mode 100644
new mode 100755
diff --git a/lib/http.js b/lib/http.js
index dcb152e..2bcfe1b 100644
--- a/lib/http.js
+++ b/lib/http.js
@@ -88,9 +88,8 @@ IncomingMessage.prototype.resume = function () {
IncomingMessage.prototype._addHeaderLine = function (field, value) {
diff --git a/lib/multipart.js b/lib/multipart.js
index a5afeff..4114569 100644
--- a/lib/multipart.js
+++ b/lib/multipart.js
@@ -51,7 +51,8 @@ proto.init = function(options) {
this.part = null;
if ('headers' in options) {
- var req = options, contentType = req.headers['content-type'];
+ var req = options,
@isaacs
isaacs / snippet.js
Created February 3, 2010 22:30 — forked from tlrobinson/2-async.js
// EXAMPLE 1: async response
// PSGI equivalent
var app = function(env) {
return function(respond) {
// do some event stuff
setTimeout(function() {
respond({ status : code, headers : headers, body : body });
}, 1000);
}
// exports defined out here.
exports.foo = "bar"
require(
"sys", "file", "persistence/sqlite3"
)(function (sys, file, sqlite) {
sys.p(File);
// Rest of program here
});