Node's util.inherits mechanism (
https://github.com/joyent/node/blob/
master/lib/util.js) for object inheritance works somewhat differently
than the 'extends' keyword in CoffeeScript, which generates the
following code:
var __hasProp = Object.prototype.hasOwnProperty, __extends =
function(child, parent) {
for (var key in parent) { if (__hasProp.call(parent, key))
child[key] = parent[key]; }
function ctor() { this.constructor = child; }
ctor.prototype = parent.prototype;
child.prototype = new ctor;
child.__super__ = parent.prototype;
return child;
};
In practical use, I have yet to notice any disadvantages to using the
CoffeeScript extends. I may just have been lucky so far, though. Does
it present any dangers when applied to Node constructors that I may
not have noticed? Does anyone know of some examples where it would be
inappropriate?
Thanks,
MLG