This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var A = function A() {}; | |
var B = function B() {}; | |
B.prototype = new A(); | |
// B.prototype.constructor = B; // only way I can find to get bi's constructor to be B. Comment or uncomment this line to produce exactly the same output for both tests. It doesn't matter. | |
// require('util').inherits(B, A); // same here. Comment or uncomment it doesn't make a difference. | |
var ai = new A(); | |
var bi = new B(); | |
console.log('Test 1: constructor directly'); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var sys = require('sys') | |
var EventEmitter = require('events').EventEmitter | |
var func = function(arg1, arg2) { | |
if(arg1 === undefined && arg2 === undefined) { | |
sys.puts("I was called without parameters"); | |
} | |
}; | |
var emitter = new EventEmitter(); | |
emitter.on('test',func) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var EventEmitter = require('events').EventEmitter | |
var Mutex = function() { | |
var queue = new EventEmitter(); | |
var locked = false; | |
this.lock = function lock(fn) { | |
if (locked) { | |
queue.once('ready',function() { | |
lock(fn); | |
}); | |
} else { |
NewerOlder