Arsenal
Version 1.3.4
A collection of various useful mechanisms for javascript applications.
Summary
Binding A mechanism implements the Data Binding.
Event The implementation of the well-known Event mechanism.
Functional For improving the programming style of asynchronous, mainly in node.js, In a functional style.
Grid Implementation of the two-dimensional grid flow algorithm.
Throttle Limit the specific procedure to be run in a certain frequency.
Trigger Invokes a specified function when all the given conditions were satisfied.
Pipeline A functional pipeline mechanism, by utilizing the Event and Functional mechanisms.
Impulse A data-driven mechanism base on Binding and Trigger mechanisms.
Installation
npm install arsenal
var Arsenal = require("arsenal");
<script type="text/javascript" src="arsenal.js"></script>
- for browsers in production:
<script type="text/javascript" src="arsenal.min.js"></script>
Customization
Use the build.js
script for your customization.
Usage: node build MECHANISM1 [MECHANISM2 ...] [OPTIONS]
Options:
-m, --minify Whether to minify the output file [default: false]
-o, --output Set path to the output file
[default: "/source/lab/osp/arsenal/build/arsenal.js"]
-q, --quiet Do not print any messages. [default: false]
-h, --help Show this help message and exit.
-V, --version Print version number and exit.
Build only with some mechanisms, just pass the mechanism names to the script:
node build event functional
To build all mechanisms, just pass all
as the mechanism name:
node build all
By default, the result file is place in the build/
directory, you can designate yours with -o FILE
option:
node build all -o /path/to/your/output/file.js
The build script ships with the minification via UglifyJS, to minify the result file, use -m
option:
node build all -m
Browser Compatibility
For old browsers have no supports for javascript 1.8.5,
e.g. IE series below IE9.
use iesucks
or other js1.8 shives:
<script type="text/javascript" src="iesucks.min.js"></script>
<script type="text/javascript" src="arsenal.min.js"></script>
Hint: Use test/index.html
to check for the compatibility of your browser.
(function (root) {
var Arsenal = {},
previousArsenal = root.Arsenal;
Arsenal.version = "1.3.4";
Arsenal.node = false;
if (typeof exports !== "undefined") {
if (typeof module !== "undefined" && module.exports) {
exports = module.exports = Arsenal;
} else {
exports.Arsenal = Arsenal;
exports.arsenal = Arsenal;
}
Arsenal.node = true;
} else {
root.Arsenal = Arsenal;
root.arsenal = Arsenal;
Arsenal.node = false;
Arsenal.noConflict = function () {
root.Arsenal = previousArsenal;
return Arsenal;
};
}