1.1.4 • Published 10 years ago

node.class v1.1.4

Weekly downloads
120
License
-
Repository
github
Last release
10 years ago

node.class

A port of John Resig Simple JavaScript Inheritance on node.js plus multiple inheritance.

Requires

Checkout package.json for dependencies.

Installation

Install through npm

npm install node.class

Usage

Require the module before using

var Class = require( 'node.class' );

Basic

var Person = Class.extend({

  // constructor
  init : function ( name, height ){
    this.name   = name;
    this.height = height;
  },

  show_name : function (){
    return this.name;
  },

  show_height : function (){
    return this.height;
  }
});

var ben = new Person( 'ben', '176' );

console.log( ben.height()); // 176

Multiple inheritance

var car = {

  init : function ( name ){
    this.name = name;
  },

  run : function (){
    // ...
  },

  stop : function (){
    // ...
  }
};

var sports_car = {

  turbo : function (){
    // ...
  }
};


var Porsche = Class.extend( car, sports_car );

var nine11 = new Porsche( '911' );

nine11.turbo();
1.1.4

10 years ago

1.1.3

10 years ago

1.1.2

10 years ago

1.1.1

10 years ago

1.1.0

10 years ago

1.0.1

12 years ago

1.0.0

12 years ago