Skip to content

Instantly share code, notes, and snippets.

@kriszyp
Created January 7, 2010 16:54
Show Gist options
  • Save kriszyp/271368 to your computer and use it in GitHub Desktop.
Save kriszyp/271368 to your computer and use it in GitHub Desktop.
var posix = require("posix");
var print = require("sys").puts;
var j = 0;
for(var i = 0;i < 3; i++){
findFile(i);
}
function findFile(i){
posix.stat("file" + i, process.O_RDONLY, 0666) // these files don't exist
.addErrback(function(e){
j++; // only makes it to about 17
print(j);
findFile(i + 10);
})
.addCallback(function(){
print("won't be called");
});
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment