processor.js Component object model library
============

[![NPM version](https://badge.fury.io/js/processor.png)](http://badge.fury.io/js/processor)

[Components repositories](https://github.com/node-components)

processor.js is a platform-independent, JavaScript node.js npm-based library for creating problem-oriented object models,
implementation of component-based architecture and application of IoC-patterns. See also [controls.js](http://aplib.github.io/controls.js) COM library.

Parameterized problem-oriented component (PPOC)

On node.js created a lot of modules for which most important are the convenience of programming and understandability of the internal architecture.
processor.js is a library which implements a design pattern "Parameterized problem-oriented component" (PPOC).

This implementation

- IoC (registration of the component constructors or fabrics).
- Allowed dynamic loading of modules.
- Infrastructure code.
 - Parent/child hierarchy, in/out stackable.
 - Events.

X. .parameters

- Parameters can be of any type, but it is convenient to use string parameters, it allows you to create clear text queries to create components.
- Specific constructor instance can be selected depending on the parameters specified during its creation.
- Parameters of the component are available after creating through a service property .parameters .

Y. .

- Component prototype provides basic methods and properties.
- Specific implementation can expand them, but try to clearly separate infrastructure and problem-oriented code, keep the problem-oriented data only in Z - .arguments.

Z. .arguments

- .arguments property is a hash object for domain-specific data.
- Arguments can be passed in method parameters object creation.


### About the syntax:

    var processor = require('processor'),
        com = processor.create;
    // using
        require('com-fs');


    // Copy files to folder

    com('fs.copy', [['libs/jquery.js', 'libs/marked.js', 'libs/bootstrap.js'], 'temp'])
        .updateSync();


    // Enumerate files in subdirectories

    var list =
        com('fs.walker [f]', [/.*\.utest\.js/i, 'src'])
            .listSync();


    // Creating object model

    // list source files
    root
        .add('source:fs.directory force', 'temp')
            ._add('file1:filereader', 'test1.dat')
            ._add('file2:filereader', 'test2.dat');
    // destination file
    root
        .add('destination:filewriter', 'temp/out.dat');
    // operation
    root.add('concat:fs.concat', [root.source.childs, root.destination]);


    // events

    root.findFirst('filereader')
        .on('watcher', function() {
            alert('oops! test1.dat file changed!');
        });


### Installing

    npm install processor

install modules

    npm install com-fs
    ...

### using

    var processor = require('processor'),
        com = processor.create;
    // using
        require('com-fs');

    // recursively walk and build file list
    com('fs.walker raw', [/.*\.js/, '/src'])
        .listSync(function(path) {
            ...
        });
    });


