Base

The base module exports two classes

Klass

Klass has follwoing features:

Klass(SuperClass:Function, module:Object, /*optional*/ inherit:Function):Function

Example


  var Klass = require('genji').Klass;

  var Person = Klass(function(name){
    this.name = name;
  }, {
    getName: function(){
      return this.name;
    }
  });

  var Worker = Person({
    init: function(name) {
      this.name += ' Worker';
    },

    work: function(task) {
      return this.getName() + ' start working on ' + task;
    }
  });

  var steve = new Worker('Steve');

  var result = steve.work('writing report');

  // 'Steve Worker start working on writing report' true true
  console.log(result, worker instanceof Worker, worker instanceof Person);

Base

(Coming soon)