0.0.11 • Published 7 years ago

uproto v0.0.11

Weekly downloads
3
License
MIT
Repository
github
Last release
7 years ago

uproto - User defined prototype system

uproto implements class inheritance for ES4 on basis of prototype. In addition, uproto supports namespaces, class registry and class import.

Getting Started

$ npm install --save uproto

Overview

Example

Here is an example:

var up = require('uproto');

//switch to namespace test
up.namespace('test');

//define a base object class extends from Object
up.createClass('Object', Object, {});

//use the base object class
var BaseObject = up.import('test.Object');

//switch to namespce test.exception
up.namespace('test.exception');

//define a base Exception class
var Exception = up.createClass('Exception', BaseObject, {
    init: function(code, message) {
        this.code = code;
        this.message = message;
    },
    toString: function() {
        return '[' + this.code + ' : ' + this.message + ']';
    }
});

//define test.exception.InputException extends from test.exception.Exception
var InputException = up.createClass('InputException', Exception);
var e = new InputException(1, "email invalid.");
console.log('' + e); //output: [1 : email invalid.]
0.0.11

7 years ago

0.0.10

7 years ago

0.0.9

7 years ago

0.0.8

7 years ago

0.0.7

7 years ago

0.0.6

7 years ago

0.0.5

7 years ago

0.0.4

7 years ago

0.0.3

7 years ago

0.0.2

7 years ago

0.0.1

7 years ago