~ubuntu-branches/ubuntu/trusty/node-inherits/trusty

« back to all changes in this revision

Viewing changes to inherits_browser.js

  • Committer: Package Import Robot
  • Author(s): Jérémy Lal
  • Date: 2013-08-15 14:57:25 UTC
  • mfrom: (1.1.1)
  • Revision ID: package-import@ubuntu.com-20130815145725-npt0afls2okmnli4
Tags: 2.0.0-1
* Change of upstream source.
* New upstream release.
* control:
  + bump Standards-Version to 3.9.4
  + canonicalize Vcs fields
  + add libjs-inherits package
  + update description to match new features
* copyright: license WTFPL2

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
if (typeof Object.create === 'function') {
 
2
  // implementation from standard node.js 'util' module
 
3
  module.exports = function inherits(ctor, superCtor) {
 
4
    ctor.super_ = superCtor
 
5
    ctor.prototype = Object.create(superCtor.prototype, {
 
6
      constructor: {
 
7
        value: ctor,
 
8
        enumerable: false,
 
9
        writable: true,
 
10
        configurable: true
 
11
      }
 
12
    });
 
13
  };
 
14
} else {
 
15
  // old school shim for old browsers
 
16
  module.exports = function inherits(ctor, superCtor) {
 
17
    ctor.super_ = superCtor
 
18
    var TempCtor = function () {}
 
19
    TempCtor.prototype = superCtor.prototype
 
20
    ctor.prototype = new TempCtor()
 
21
    ctor.prototype.constructor = ctor
 
22
  }
 
23
}