ITSA userguides

version 1.0.0
home
Quick jump to ITSA modules documentation
View ITSA Modules
How to use ITSA modules

ITSA modules are CommonJS-modules which can be used in nodejs or on the browser. In both cases, you reference them with require('modulename').

With nodejs

Your project will have these three elements:

You can create your own package.json, or start with our distribution package.json. It is important that every require() you use inside your scriptfile has its dependency defined inside package.json. Once you have set package.json up, you run npm install which will create node_modules and all the required packages.

From there, you can start writing your scriptfile, which probably looks something like this:

Example scripfile.js

var express = require('express'),
    ITSA = require('itsa'); // this is ITSA's rollup file
ITSA is a namespace to 'itsa', which we created inside our package.json distribution. It has all ITSA's modules in the namespace. They are available like: ITSA.Event and ITSA.IO, see the moduledocumentation how to use these modules.

If you are more familiair with creating package.json-files, you might want to customize and choose only those modules you need. Read more about it at ITSA customized build.

In the browser:

Because the browser doesn't support "require()", you need to bundled loader-file (bundled with Browerify). Browserify inspects your code and creates a single bundle-file that holds all the requirements (and its dependencies) and will define the require()-method in the browser.

The easiest way is to use our predefined loaderfiles. You can choose either to use the minified version itsabuild-min.js (advisable) or the full-version itsabuild.js for debugging.

The build-file should be included by a script tag at the bottom of the document, just above </body>. Followed by your code, which is within a <script>-tag itself:

<script src="/itsabuild-min.js"></script>
<script>
    Event = ITSA.Event;
</script>
ITSA is a namespace to 'itsa', which we created inside our package.json distribution. It has all ITSA's modules in the namespace. They are available like: ITSA.Event and ITSA.IO, see the moduledocumentation how to use these modules.

Drawback of our build-files is, that they have all of ITSA's modules inside which might be more than you need. If you are more familiair with using ITSA, you might want to customize the build-files yourself.

Customizing