Provides object-oriented programming techniques.
JavaScript Makefile HTML
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Failed to load latest commit information.
test
.gitignore
LICENSE
Makefile
README.md
bower.json
class.js
component.json
package.json

README.md

Anchor/Class

The class module provides object-oriented programming techniques, including inheritance and mixins, to the Anchor platform.

Install

component
$ component install anchorjs/class
volo
$ volo add anchorjs/class

Usage

Inheritance

To inherit a class from a subclass, invoke inherits(), passing the constructor and super constructor as arguments.

function Cat() {
  Cat.super_.call(this);
};

clazz.inherits(Cat, Animal);

Mixins

To augment a class with functions of a mixin object, invoke augment().

var HousePet = {
  eat: function() {},
  sleep: function() {}
}

clazz.augment(Cat, HousePet);

Compatibility

browser support

component

This module uses the AMD format. To include in component builds, use component-amd:

component build -u component-amd

Tests

To run tests in a browser, execute the Make target for the desired browser:

$ make test-chrome
$ make test-firefox
$ make test-safari

Headless tests can be executed directly from a terminal:

$ make test-phantomjs

Credits

License

The MIT License

Copyright (c) 2012-2013 Jared Hanson <http://jaredhanson.net/>