Browse Source

sys.inherts to shadow constructor property from enumerability

thanks to ES5 features in V8 it is quite easily possible.
v0.7.4-release
Dmitry Baranovskiy 15 years ago
committed by Ryan Dahl
parent
commit
d3f04933f1
  1. 12
      lib/sys.js

12
lib/sys.js

@ -315,9 +315,11 @@ exports.pump = function (readStream, writeStream, callback) {
* @param {function} superCtor Constructor function to inherit prototype from * @param {function} superCtor Constructor function to inherit prototype from
*/ */
exports.inherits = function (ctor, superCtor) { exports.inherits = function (ctor, superCtor) {
var tempCtor = function(){}; ctor.super_ = superCtor;
tempCtor.prototype = superCtor.prototype; ctor.prototype = Object.create(superCtor.prototype, {
ctor.super_ = superCtor; constructor: {
ctor.prototype = new tempCtor(); value: ctor,
ctor.prototype.constructor = ctor; enumerable: false
}
});
}; };

Loading…
Cancel
Save