diff options
author | Dmitry Baranovskiy <Dmitry@Baranovskiy.com> | 2010-06-28 11:05:22 +1000 |
---|---|---|
committer | Ryan Dahl <ry@tinyclouds.org> | 2010-06-29 19:11:40 -0700 |
commit | d3f04933f151b233ccd1972a933d0e9873d78ca5 (patch) | |
tree | 7d6b52494a17b04555739fdc2bccc59966d08030 /lib/sys.js | |
parent | 6b430a95c9a8c965f32d641dced169e6cecd61d6 (diff) | |
download | node-new-d3f04933f151b233ccd1972a933d0e9873d78ca5.tar.gz |
sys.inherts to shadow constructor property from enumerability
thanks to ES5 features in V8 it is quite easily possible.
Diffstat (limited to 'lib/sys.js')
-rw-r--r-- | lib/sys.js | 12 |
1 files changed, 7 insertions, 5 deletions
diff --git a/lib/sys.js b/lib/sys.js index f877dad117..ac8b023c4b 100644 --- a/lib/sys.js +++ b/lib/sys.js @@ -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 + } + }); }; |