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
diff --git a/lib/uri.js b/lib/uri.js
index 45187e0..e44dd40 100644
--- a/lib/uri.js
+++ b/lib/uri.js
@@ -96,20 +96,7 @@ function uri_parse (url) {
}
/* normalize */
- var directories = [];
- for (var i = 0; i < items.directories.length; i++) {
---- PARSE TESTS ----
uri fail http://example.com?foo=@bar#frag
expected:
{"href":"http://example.com?foo=@bar#frag","protocol":"http:","host":"example.com","hostname":"example.com","hash":"#frag","search":"?foo=@bar","query":"foo=@bar"}
actual:
{"href":"http://example.com?foo=@bar#frag","protocol":"http:","host":"example.com?foo=@bar","hostname":"bar","hash":"#frag","query":""}
---- RESOLVE TESTS ----
// url-rfc module
// Just like node's url module, but using the same names used in various UR[LI] RFCs
var url = require("url"),
path = require("path");
exports.parse = function (str) {
var parsed = url.parse(str);
var out = {};
if (parsed.protocol) out.scheme = parsed.protocol.substr(-1);
var url = require("url"),
path = require("path");
exports.parse = function (str) {
var parsed = url.parse(str);
return {
get scheme : function () { return parsed.protocol ? parsed.protocol.substr(-1) : undefined },
get authorityRoot : function () { return parsed.slashes ? "//" : undefined },
get authority : function () { return parsed.host },
get userInfo : function () { return parsed.auth },
var posix = require("posix"),
print = require("sys").puts,
successes = {},
// number of files to inspect on each pass
N = 10,
// degree of concurrency
C = 5,
// print lots of stuff, or just a little?
verbose = true,
// use a timeout, or call synchronously
chain
(addCustomHeaders)
(errorHandler)
(deflate)
(route
("/foo", chain(fooApp)()) // the () ends the chain
(/^\/blog\/(.*)/, chain(funkyBlogApp)()) // the () ends the chain
(/^\/static\//, chain
(farFutureExpiresHeader)
(route
$ node bench.js
Scores: (bigger is better)
with(){}
0.4821178821178821
0.48431568431568434
0.4651487916916317
0.4757242757242757
Average (mean) 0.47682665846236844
@isaacs
isaacs / DAG!
Created January 11, 2010 06:20 — forked from hassox/chain-example.js
/(B)---------------
--(A)--* /(D)--| \
\(C)---* --(G)--(H)
\(E)--(F)--/
chain
(A)
(route
("/B", B) // single link, then fallthrough, don't need a chain
("/C", chain
chain
(myApp)
(route
(function (req) {
return req.header("accept").indexOf("application/json") !== -1
}, chain(renderAsJSON)())) // terminal, and end route
(render)
(as)
(template)
().listen(8000);
Statistical profiling result from v8.log, (30169 ticks, 1042 unaccounted, 0 excluded).
[Unknown]:
ticks total nonlib name
1042 3.5%
[Shared libraries]:
ticks total nonlib name
[JavaScript]: