Skip to content
This repository has been archived by the owner on Apr 22, 2023. It is now read-only.

Commit

Permalink
sys.inherts to shadow constructor property from enumerability
Browse files Browse the repository at this point in the history
thanks to ES5 features in V8 it is quite easily possible.
  • Loading branch information
DmitryBaranovskiy authored and ry committed Jun 30, 2010
1 parent 6b430a9 commit d3f0493
Showing 1 changed file with 7 additions and 5 deletions.
12 changes: 7 additions & 5 deletions lib/sys.js
Original file line number Diff line number Diff line change
Expand Up @@ -315,9 +315,11 @@ exports.pump = function (readStream, writeStream, callback) {
* @param {function} superCtor Constructor function to inherit prototype from
*/
exports.inherits = function (ctor, superCtor) {
var tempCtor = function(){};
tempCtor.prototype = superCtor.prototype;
ctor.super_ = superCtor;
ctor.prototype = new tempCtor();
ctor.prototype.constructor = ctor;
ctor.super_ = superCtor;
ctor.prototype = Object.create(superCtor.prototype, {
constructor: {
value: ctor,
enumerable: false
}
});
};

0 comments on commit d3f0493

Please sign in to comment.