> An OOP framework for Node.js and the browser
An OOP framework for Node.js and the browser
_super(), and an
init() method that runs after construction is complete.
instance.constructor all work as expected.
Mixins can be added when a class is declared using the
mixins option or after instantiation with the
Stay classy and boilerplate-free with string-based
toString declarations and automatic chaining of
Make instance properties non-writable, non-enumerable, or employ setters & getters with the
properties option, then inherit and override individually.
PseudoClass is completely standalone. All you need to stay classy is
As PseudoClass makes use of ECMAScript 5 features, it is only compatible with modern browsers.
PseudoClass can be used in a Node, AMD, or browser environment out of the box.
PseudoClass empowers you without getting in your way. See the examples below to see how PseudoClass makes prototypal inheritance painless.
var Parent = ClasstoString: 'Parent'properties:visible:value: trueenumerable: trueconsole.log'Parent: Constructing';console.log'Parent: Destructing';console.log'Parent: Doing stuff';;
A mixin is a set methods you can plug into any class. Mixins can use
_super, just like normal methods.
var stuffDoer =this_super;console.log'Mixin: Doing stuff';;
Mixins added at declaration time become part of the prototype.
var Child = ParentextendtoString: 'Child'mixins: stuffDoerproperties:visible:value: false // Only override the valueconsole.logthis+': Constructing';console.logthis+': Destructing';this_super;console.logthis+': Doing stuff';;
var child = new Child();/* Output:Parent: ConstructingChild: Constructing*/
childdoStuff;/* Output:Parent: Doing stuffChild: Doing stuffMixin: Doing stuff*/
Mixins added after instantiation become part of the instance.
childmixinconsole.logthis+': Doing more stuff';childdoMoreStuff;/* Output:Child: Doing more stuff*/
console.logchildinstanceOfChild; // trueconsole.logchildinstanceOfParent; // trueconsole.logchildconstructor === Child // trueconsole.logchild+''; // 'Child'
childdestruct;/* Output:Child: DestructingParent: Destructing*/
PseudoClass is always accessible as
PseudoClass. If you're using another library that defines
Class, you can still use PseudoClass by referencing
PseudoClass is licensed under the permissive BSD license.