######## main.js ########
var assert = require("assert");
var BaseObject = require("./base").BaseObject;
var ObjectA = require("./a").ObjectA;
var objA = new ObjectA();
assert.ok(objA instanceof BaseObject); // FAILS!
######## base.js ########
function BaseObject() {};
exports.BaseObject = BaseObject;
######## a.js ########
var BaseObject = require("./base").BaseObject;
function ObjectA() {
BaseObject.call(this);
};
process.inherits(ObjectA, BaseObject);
exports.ObjectA = ObjectA;
I had the same problem and it happened when node 0.1.28 was released
(I think it has something to do with the new way the modules are
loaded). I solved it by adding a className variable in my objects and
then using that to check the type of object instead of instanceof
exports.BaseObject = function() {
this.className = "BaseObject";
}
assert(objA.className == "BaseObject")
Anyone know any other way ?
Christian
http://github.com/felixge/node/commit/4718208a138a68a6b0047d6734130981b827e9ee
Let me know what you think ryan,
--fg
On Feb 11, 10:14 pm, Felix Geisendörfer <fe...@debuggable.com> wrote:
> Sorry about that. I got this wrong when I simplified the module
> system, but this patch should fix it:
>
> http://github.com/felixge/node/commit/4718208a138a68a6b0047d673413098...
Thanks Felix, landed in b02b54e.