Created
December 20, 2011 19:56
Revisions
-
Raynos revised this gist
Jan 20, 2012 . 1 changed file with 3 additions and 0 deletions.There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -1,3 +1,6 @@ // https://github.com/Raynos/pd var pd = typeof window === "undefined" ? require("pd") : window.pd; var klass = (function() { // meta data name var meta = pd.Name(); -
Raynos revised this gist
Jan 20, 2012 . 1 changed file with 1 addition and 1 deletion.There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -21,7 +21,7 @@ var klass = (function() { } // create new prototype object by inheriting from Parent var proto = pd.extend(Object.create(parent.prototype), child(privates, parent.prototype)); // fix constructor <-> prototype link proto.constructor.prototype = proto; -
Raynos revised this gist
Dec 20, 2011 . 1 changed file with 1 addition and 1 deletion.There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -21,7 +21,7 @@ var klass = (function() { } // create new prototype object by inheriting from Parent var proto = pd.make(parent.prototype, child(privates, parent.prototype)); // fix constructor <-> prototype link proto.constructor.prototype = proto; -
Raynos revised this gist
Dec 20, 2011 . 1 changed file with 10 additions and 1 deletion.There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -1,26 +1,35 @@ var klass = (function() { // meta data name var meta = pd.Name(); return klass; function klass(parent, child) { // if one argument set parent to Object if (!child) { child = parent; parent = Object; } if (parent !== Object) { // extract privates from meta data on parent var privates = meta(parent).privates; } else { // if parent is object create new name var privates = pd.Name(); } // create new prototype object by inheriting from Parent var proto = pd.make(Parent.prototype, child(privates, parent.prototype)); // fix constructor <-> prototype link proto.constructor.prototype = proto; // get the constructor function var constructor = proto.constructor; // store the privates as meta data on this constructor meta(constructor).privates = privates; return constructor; } })(); -
Raynos revised this gist
Dec 20, 2011 . 1 changed file with 1 addition and 2 deletions.There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -15,8 +15,7 @@ var klass = (function() { var privates = pd.Name(); } var proto = pd.make(Parent.prototype, child(privates, parent.prototype)); proto.constructor.prototype = proto; -
Raynos created this gist
Dec 20, 2011 .There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,27 @@ var klass = (function() { var meta = pd.Name(); return klass; function klass(parent, child) { if (!child) { child = parent; parent = Object; } if (parent !== Object) { var privates = meta(parent).privates; } else { var privates = pd.Name(); } var proto = Object.create(parent.prototype); pd.extend(proto, child(privates, parent.prototype)); proto.constructor.prototype = proto; var constructor = proto.constructor; meta(constructor).privates = privates; return constructor; } })();