Skip to content
Create a gist now

Instantly share code, notes, and snippets.

Embed URL


Subversion checkout URL

You can clone with
Download ZIP
var pd = typeof window === "undefined" ? require("pd") : window.pd;
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.extend(Object.create(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;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Something went wrong with that request. Please try again.