0.2.0 • Published 8 years ago

matis v0.2.0

Weekly downloads
1
License
GPL-3.0
Repository
github
Last release
8 years ago

MATIS

Multi-level Asynchrounous Tools Interconnection System

Fast complex asynchrounous processes made easy.

npm install matis

More documentation here.

Example

                           |
                           | path
                      +----------+
                      | loadBody |
                      +----------+
                    path |    | text
                         |    |
                 +-------+--( | )----------+
                 |            |            |
            path |            |            | path
        +------------------+  |  +------------------+
        | changeExtForHead |  |  | changeExtForFoot |
        +------------------+  |  +------------------+
        path |                |              | path
             |                |              |
        path |                |              | path
       +------------+         |         +------------+
       | existsHead |         |         | existsFoot |
       +------------+         |         +------------+
       no |       | yes       |       yes |       | no
          |       |           |           |       |
     void |       | path      |      path |       | void
+-----------+   +----------+  |  +----------+   +-----------+
| constHead |   | loadHead |  |  | loadHead |   | constHead |
+-----------+   +----------+  |  +----------+   +-----------+
     text |       | text      |      text |       | text
          |       |           |           |       |
          +---+---+           |           +---+---+
              |               |               |
              +------------+  |  +------------+
                           |  |  |
                           | b|  | 
                           | o|  |
                           | d|  |
                      head | y|  | foot
                         +--------+
                         | concat |
                         +--------+
                             | text
                             |
var Matis = require("async-tools");

var process = Matis.Process(function() {
    this.Start = Matis.tools.Nop().name('start');
    this.LoadBody = Matis.tools.LoadText('utf-8');
    this.LoadHead = Matis.tools.LoadText('utf-8');
    this.LoadFoot = Matis.tools.LoadText('utf-8');
    this.ChangeExtForHead = Matis.tools.ChangeExtension({js: "head"});
    this.ChangeExtForFoot = Matis.tools.ChangeExtension({js: "foot"});
    this.ExistsHead = Matis.tools.ExistsFile();
    this.ExistsFoot = Matis.tools.ExistsFile();
    this.ConstHead = Matis.tools.Constant("// Missing header.\n");
    this.ConstFoot = Matis.tools.Constant("// Missing footer.\n");
    this.Concat = Matis.tools.ConcatStrings(['head', 'body', 'foot']);
}, [
    "Start > LoadBody > body:Concat",    
    "Start > ChangeExtForHead > ExistsHead:yes > LoadHead > head:Concat",
    "Start > ChangeExtForFoot > ExistsFoot:yes > LoadFoot > foot:Concat",
    "ExistsHead:no > ConstHead > head:Concat",
    "ExistsFoot:no > ConstFoot > foot:Concat"
]);

// Execute.
process.exec(
    { path: 'myfile.js' },
    function (output) {
        console.log("Result is: " + output.text);
    },
    function (err) {
        console.error("Error: " + err);
    }
);