0.0.8 • Published 10 years ago

modulusjs v0.0.8

Weekly downloads
30
License
-
Repository
github
Last release
10 years ago

Modulus

Drop dead simple module definition library.

Modulus simplifies your module definitions by autowiring module function parameters based on the paramater name. e.g. having a parameter called moduleA in your module function will result in modulus finding moduleA and passing it to your module function.

Try it out!

You can play with the specs by going here and selecting Project -> Fork.

View the test results here

##Defining Modules To define a module, simply create a named function:

//defining a module is as simple as creating a function.
function moduleA(){
    return {
        prop1: 123
    };
}

//simply by referencing moduleA, you will get its return value passed in as the parameter value.
function moduleB(moduleA){
    return {
        prop1: moduleA.prop1 + 1
    };
}

##Start Processing

Option 1 - module metadata

Each module can have metadata to control behavior of modulus. By specifying autoInit = true, modulus knows to run the function once it's dependencies have been located.

//configure the module to execute without being required by another module first.
moduleB.module = {
    autoInit: true
};

//start processing
modulus.init();

Option 2

modulus.init();

modulus.require(function (moduleB){
    console.log(moduleB.prop1); //prints 124
});

AMD

Build Time Option

Configuration

0.0.8

10 years ago

0.0.6

10 years ago

0.0.5

10 years ago

0.0.4

10 years ago

0.0.3

10 years ago

0.0.2

10 years ago

0.0.1

10 years ago