Permalink
Browse files

here 'tis

  • Loading branch information...
1 parent ab68ae6 commit 19bc5cca4d8f6100ff5aff22af234c6016e64e87 @isaacs committed Apr 7, 2011
Showing with 35 additions and 0 deletions.
  1. +29 −0 inherits.js
  2. +6 −0 package.json
View
@@ -0,0 +1,29 @@
+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
View
@@ -0,0 +1,6 @@
+{ "name" : "inherits"
+, "description": "A tiny simple way to do classic inheritance in js"
+, "version" : "1.0.0"
+, "keywords" : ["inheritance", "class", "klass", "oop", "object-oriented"]
+, "main" : "./inherits.js"
+, "author" : "Isaac Z. Schlueter <i@izs.me> (http://blog.izs.me/)" }

0 comments on commit 19bc5cc

Please sign in to comment.