Light and fast Class implementation for JavaScript, no fancy stuff or wrapped methods.
However it has a .parent
method.
This is a bit experimenting, so don't expect too much ;)
Should work in Node.js too.
As much as is in Klass.html and Klass-node.js, so not much. Also only in Chrome and Node
- Events
- Store
- Options
- Bind
- Chain
- Map
var myClass = new Klass(parent, methods, mixin1, mixin2, ...);
- myClass.implement - add new methods to the prototype
- myClass.extend - add static functions to the class
- myClass.decorate - decorate or replace old methods
- myClass.alias - aliases to methods
// Parent Class
var DarthVader = new Klass(null, {
init: function(){
},
fight: function(arg1, arg2, arg3){ … }
});
// Child
var Luke = new Klass(DarthVader, {
fight: function(){
return this.parent('fight', [arg1, arg2, arg3]);
}
});
Most stuff is pretty directly taken from MooTools. Use that if you want something stable, it's FTW!