Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Yet Another Class
JavaScript
branch: master

Fetching latest commit…

Cannot retrieve the latest commit at this time

Failed to load latest commit information.
Source
Klass-node.js
Klass.html
README.md

README.md

Klass

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.

Tested

As much as is in Klass.html and Klass-node.js, so not much. Also only in Chrome and Node

Mixins

  • Events
  • Store
  • Options
  • Bind
  • Chain

Other Classes

  • Map

Example

var myClass = new Klass(parent, methods, mixin1, mixin2, ...);

Methods

  • 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

Extending Classes

// 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]);
    }
});

Notes

Most stuff is pretty directly taken from MooTools. Use that if you want something stable, it's FTW!

Something went wrong with that request. Please try again.