Craydent NOOF 0.2.3
by Clark Inada
NOOF (Node Object Oriented Framework) module is a framework to enable object oriented practices to JavaScript. With this module, you are able define:
- Namespaces
- Interfaces
- Abstract Classes
- Public Classes
- Overloading methods
- Private methods/properties
- Protected methods/properties
- Public methods/properties
- Constructors
- Destructors
- Strongly typed variables and parameters
NOOF provides the ability to created extensions to classes and intreface implementation which are all checked on start/load as well as the ability to import namespaces to the current scope.
**Note: A semi-colon (;) as the end of every NOOF directive is required.
*Note: Checking method parameter/variable types can only be done through run time so it is still important to run unit tests to test your own code.
Usages
There are 2 ways to require NOOF
var $n = ; // OR // when using this require, remove the "$n." prefix in all the examples below.;
Defining typed method parameters & variables (the type is case sensitive)
privatevariable = "";privateStringstr = ""; protectedvariable = "";protectedStringstr = ""; publicvariable = "";publicStringstr = ""; privatemethod { /* your code goes here */ };protectedmethod { /* your code goes here */ };publicmethod { /* your code goes here */ }; // Specify a return type.// Return types are checked at runtime and will throw errors when specified type is not returnedprivatemethodBoolean { /* your code goes here */ };protectedmethodBoolean { /* your code goes here */ };publicmethodBoolean { /* your code goes here */ };
Overloading methods
publicmethod = { /* your code goes here */ };publicmethod = { /* your code goes here */ };publicmethod = { /* your code goes here */ };publicmethod = { /* your code goes here */ };publicmethod = { /* your code goes here */ };
Defining Namespaces
var $n = ;// this will declare User in the public scope as well as the namespace scope$n// this will only declare User in the namespace scope$n
Using Namespaces
var $n = ;$n { var NOOF = $n; ver u = ;} { var User = $n; ver u = ;} { ; // setting the second argument to true returns a stringified version of the classes. ver u = ; // this is useful for closure when the class needs to use a variable in the parent scope.}
Defining Interfaces
var $n = ;$n
Defining Abstract Classes
var $n = ;$n;
Defining Public
var $n = ;$n
Implementing Interfaces
var $n = ;$n;
Extending Classes
var $n = ;$n;
Extending Class and then Implementing Interface
var $n = ;$n;
Installation
$ npm i --save noof
Download
The Craydent NOOF is released under the Dual licensed under the MIT or GPL Version 2 licenses.