monoclass

MONOCLASS, a compiler of JSON-based classes using Node.JS

MONOCLASS

MONOCLASS is a spec of JSON-based classes that when compiled provide full OOP features.

Read the MONOCLASS full specification (needs some updates).

Example of Animal class.

module.exports = {
    
    private: {
        _age: 1
    }
 
    constructorfunction (age:::Number) {
        _age = age || 1;
    },
 
    getAgefunction () {
        return age;
    }
 
};

Example of Dog class. (Dog.js)

module.exports = {
    
    extend: ['Animal'],
 
    talkfunction () {
        console.log("Woof Woof Woof!")
    }
 
};
$ npm install monoclass
var compiler = require('monoclass')
var classSource = fs.readFileSync('monoclassy.js')
 
var monoclassy = compiler.addClass('monoclassy', classSource)
 
var instance = new monoclassy;
var compiler = require('monoclass')
var monoclassy = compiler.addFile('monoclassy.js',true);
var instance = new monoclassy;
var compiler = require('monoclass')
var monoclassy = compiler.addClass('monoclassy', {
    constructorfunction () {
        console.log('hello')
    }
},true);
var instance = new monoclassy;
var compiler = require('monoclass')
var monoclassy = compiler.addSource('monoclassy', 'module.exports = { constructor: function () { console.log("hello"); } };',true);
var instance = new monoclassy;
$ monoclass [options] <monoclass file> 

For others commands, type: monoclass -h

MIT