inherits
Advanced tools
Comparing version 2.0.3 to 2.0.4
if (typeof Object.create === 'function') { | ||
// implementation from standard node.js 'util' module | ||
module.exports = function inherits(ctor, superCtor) { | ||
ctor.super_ = superCtor | ||
ctor.prototype = Object.create(superCtor.prototype, { | ||
constructor: { | ||
value: ctor, | ||
enumerable: false, | ||
writable: true, | ||
configurable: true | ||
} | ||
}); | ||
if (superCtor) { | ||
ctor.super_ = superCtor | ||
ctor.prototype = Object.create(superCtor.prototype, { | ||
constructor: { | ||
value: ctor, | ||
enumerable: false, | ||
writable: true, | ||
configurable: true | ||
} | ||
}) | ||
} | ||
}; | ||
@@ -17,8 +19,10 @@ } else { | ||
module.exports = function inherits(ctor, superCtor) { | ||
ctor.super_ = superCtor | ||
var TempCtor = function () {} | ||
TempCtor.prototype = superCtor.prototype | ||
ctor.prototype = new TempCtor() | ||
ctor.prototype.constructor = ctor | ||
if (superCtor) { | ||
ctor.super_ = superCtor | ||
var TempCtor = function () {} | ||
TempCtor.prototype = superCtor.prototype | ||
ctor.prototype = new TempCtor() | ||
ctor.prototype.constructor = ctor | ||
} | ||
} | ||
} |
try { | ||
var util = require('util'); | ||
/* istanbul ignore next */ | ||
if (typeof util.inherits !== 'function') throw ''; | ||
module.exports = util.inherits; | ||
} catch (e) { | ||
/* istanbul ignore next */ | ||
module.exports = require('./inherits_browser.js'); | ||
} |
{ | ||
"name": "inherits", | ||
"description": "Browser-friendly inheritance fully compatible with standard node.js inherits()", | ||
"version": "2.0.3", | ||
"version": "2.0.4", | ||
"keywords": [ | ||
@@ -20,6 +20,6 @@ "inheritance", | ||
"scripts": { | ||
"test": "node test" | ||
"test": "tap" | ||
}, | ||
"devDependencies": { | ||
"tap": "^7.1.0" | ||
"tap": "^14.2.4" | ||
}, | ||
@@ -26,0 +26,0 @@ "files": [ |
3958
36