Share your code. npm Orgs help your team discover, share, and reuse code. Create a free org »

    monoclasspublic

    MONOCLASS

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

    Specification

    Read the MONOCLASS full specification (needs some updates).

    Example

    Example of Animal class.

    module.exports = {
        
        private: {
            _age: 1
        }
     
        constructor: function (age:::Number) {
            _age = age || 1;
        },
     
        getAge: function () {
            return age;
        }
     
    };

    Example of Dog class. (Dog.js)

    module.exports = {
        
        extend: ['Animal'],
     
        talk: function () {
            console.log("Woof Woof Woof!")
        }
     
    };

    Compiler

    Installation

    $ npm install monoclass

    Load from file (long version)

    var compiler = require('monoclass')
    var classSource = fs.readFileSync('monoclassy.js')
     
    var monoclassy = compiler.addClass('monoclassy', classSource)
     
    var instance = new monoclassy;

    Load from file (short version)

    var compiler = require('monoclass')
    var monoclassy = compiler.addFile('monoclassy.js',true);
    var instance = new monoclassy;

    Load from literal object

    var compiler = require('monoclass')
    var monoclassy = compiler.addClass('monoclassy', {
        constructor: function () {
            console.log('hello')
        }
    },true);
    var instance = new monoclassy;

    Load from inline source string

    var compiler = require('monoclass')
    var monoclassy = compiler.addSource('monoclassy', 'module.exports = { constructor: function () { console.log("hello"); } };',true);
    var instance = new monoclassy;

    Command line

    $ monoclass [options] <monoclass file> 

    For others commands, type: monoclass -h

    Community

    Cases

    License

    MIT

    install

    npm i monoclass

    Downloadsweekly downloads

    14

    version

    0.3.1

    license

    MIT

    repository

    github.com

    last publish

    collaborators

    • avatar