0.0.1 • Published 10 years ago

classesjs v0.0.1

Weekly downloads
4
License
MIT
Repository
github
Last release
10 years ago

classesjs

A small library to standardize Class creation in javascript

Exemples:

var Class = require('./index');

var Person = Class({
	__construct : function() {
		arguments.callee.parent.__construct.apply(this, arguments);
		
	},
	name	: '',
	getName	: function() {
		return this.name;
	},
	setName	: function( name ) {
		this.name = name;
	}
});

var NormalPerson = Class(Person, {
	freeHours : 0,
	setFreeHours : function( n ) {
		this.freeHours = n;
	},
	getFreeHours : function() {
		return this.freeHours;
	}
});


var Programmer = Class(NormalPerson, {
	__construct : function() {
		arguments.callee.parent.__construct.apply(this, arguments);
		
	},
	getFreeHours : function() {
		//Programmers not have FreeHours.
		return 0;
	}
});


var person = new NormalPerson();
person.setFreeHours( 10 );
console.log( person.getFreeHours() );//Should be 10


var programmer = new Programmer();
programmer.setFreeHours( 10 );
console.log( programmer.getFreeHours() );//Should be 0