Skip to content

Instantly share code, notes, and snippets.

loadModule REQUEST path parent: ../common
load native module path
loadModule REQUEST assert parent: ../common
load native module assert
loadModule REQUEST util parent: ../common
load native module util
loadModule REQUEST path parent: .
load native module path
loadModule REQUEST net parent: .
load native module net
closed 100
closed 103
closed 99
node.js:58
throw e; // process.nextTick error, or 'error' event on first tick
^
AssertionError: 99 was one of the first closed connections but shouldnt have been
at Stream.<anonymous> (/home/aconbere/Projects/javascript/node/test/simple/test-net-server-max-connections.js:54:16)
at Stream.emit (events.js:31:17)
// needs to handle the following cases
//
// require("a.<ext>")
// -> a.<ext>
//
// require("a")
// -> a
// -> a.<ext>
// -> a/index.<ext>
function findModulePath (request, paths) {
// needs to handle the following cases
//
// require("a.<ext>")
// -> a.<ext>
//
// require("a")
// -> a
// -> a.<ext>
// -> a/index.<ext>
// needs to handle the following cases
//
// require("a.<ext>")
// -> a.<ext>
//
// require("a")
// -> a
// -> a.<ext>
// -> a/index.<ext>
// needs to handle the following cases
//
// require("a.<ext>")
// -> a.<ext>
//
// require("a")
// -> a
// -> a.<ext>
// -> a/index.<ext>
// Which files to traverse while finding id? Returns generator function.
function traverser (id, dirs) {
var head = [],
inDir = [],
dirs = dirs.slice(), // a copy of the original array
exts = Object.keys(extensions);
return function next () {
var result = head.shift();
if (result) { return result; }
@aconbere
aconbere / gist:715763
Created November 25, 2010 18:26
Non-closured-walk
var fs = require("fs");
var path = require("path");
var handleReadDirFactory = function (start, callback) {
var handleReadDir = function (err, files) {
if (err) return callback(err)
var dirs = []
, notDirs = []
, IL = files.length
@aconbere
aconbere / gist:714339
Created November 24, 2010 20:26
JS async walk
var fs = require("fs");
var path = require("path");
var walk = function (start, callback) {
fs.lstat(start, function (err, stat) {
if (err) return callback(err)
if (stat.isDirectory() && !stat.isSymbolicLink()) {
fs.readdir(start, function (err, files) {
if (err) return callback(err)
----------
/ \
/ REST \
/ IN \
/ PEACE \
/ \
| aconbere |
| 897 Au |
| killed by a |
| giant bat |