mirror of https://github.com/lukechilds/node.git
You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
30 lines
862 B
30 lines
862 B
13 years ago
|
module.exports = inherits
|
||
|
|
||
|
function inherits (c, p, proto) {
|
||
|
proto = proto || {}
|
||
|
var e = {}
|
||
|
;[c.prototype, proto].forEach(function (s) {
|
||
|
Object.getOwnPropertyNames(s).forEach(function (k) {
|
||
|
e[k] = Object.getOwnPropertyDescriptor(s, k)
|
||
|
})
|
||
|
})
|
||
|
c.prototype = Object.create(p.prototype, e)
|
||
|
c.super = p
|
||
|
}
|
||
|
|
||
|
//function Child () {
|
||
|
// Child.super.call(this)
|
||
|
// console.error([this
|
||
|
// ,this.constructor
|
||
|
// ,this.constructor === Child
|
||
|
// ,this.constructor.super === Parent
|
||
|
// ,Object.getPrototypeOf(this) === Child.prototype
|
||
|
// ,Object.getPrototypeOf(Object.getPrototypeOf(this))
|
||
|
// === Parent.prototype
|
||
|
// ,this instanceof Child
|
||
|
// ,this instanceof Parent])
|
||
|
//}
|
||
|
//function Parent () {}
|
||
|
//inherits(Child, Parent)
|
||
|
//new Child
|