processor.js
function(index, type, /*optional*/ $prime, /*optional*/ args, /*optional*/ callback, /*optional*/ this_arg) {

            if (!type)
                return;

            // normalize arguments
            if (typeof $prime === 'function') {
                this_arg = args;
                callback = $prime;
                $prime = undefined;
                args = undefined;
            } else {
                if (typeof $prime === 'object' && !Array.isArray($prime)) {
                    this_arg = callback;
                    callback = args;
                    args = $prime;
                    $prime = undefined;
                }
                if (typeof args === 'function') {
                    this_arg = callback;
                    callback = args;
                    args = undefined;
                }
            }

            if (Array.isArray(type)) {
                // collection detected
                var result;
                for(var i = index, c = index + type.length; i < c; i++)
                    result = this.insert(i, type[i], $prime, args, callback, this_arg);
                return result;
            }
            
            if (typeof type === 'object') {
                // it is a control?
                var add_task = type;
                if (add_task.hasOwnProperty('__type'))
                    setParent.call(type, this, index);
                return add_task;
            }

            if (Array.isArray(args))
                args = {'': args};
            else if (!args)
                args = {};
            var parameters = {};
            
            // transfer inheritable parameters to the created object
            var this_parameters = this.parameters;
            for(var prop in this_parameters)
                if (this_parameters.hasOwnProperty(prop) && prop[0] === '/')
                    parameters[prop] = this_parameters[prop];
            
            // resolve constructor
            var __type = parse_type(type, parameters, args),
                constructor = resolve_ctr(__type, parameters);
            
            if ($prime !== undefined)
                args[''] = $prime;
            
            // load required components
            if (!constructor) {
                var parts = __type.split('.'),
                    mod_path = './modules/' + parts[0] + '/' + parts[1];
                console.log(__type + ' not loaded, try to load ' + mod_path);
                require(mod_path);
                constructor = resolve_ctr(__type, parameters);
            }
            
            if (!constructor)
                throw new TypeError('Type ' + __type + ' not registered!');
            
            // move $parameters to attributes (unsafe)
            for(var prop in parameters)
                if (parameters.hasOwnProperty(prop) && prop[0] === '$')
                    args[prop.substr(1)] = parameters[prop];
            
            // create control

            var new_control = new constructor(parameters, args);

            // reflect after creation
            new_control.raise('type');

            // set parent property
            setParent.call(new_control, this, index);

            // callback
            if (callback)
                callback.call(this_arg || this, new_control);

            return new_control;
        }
function(index, type, /*optional*/ $prime, /*optional*/ args, /*optional*/ callback, /*optional*/ this_arg) {

            if (!type)
                return;

            // normalize arguments
            if (typeof $prime === 'function') {
                this_arg = args;
                callback = $prime;
                $prime = undefined;
                args = undefined;
            } else {
                if (typeof $prime === 'object' && !Array.isArray($prime)) {
                    this_arg = callback;
                    callback = args;
                    args = $prime;
                    $prime = undefined;
                }
                if (typeof args === 'function') {
                    this_arg = callback;
                    callback = args;
                    args = undefined;
                }
            }

            if (Array.isArray(type)) {
                // collection detected
                var result;
                for(var i = index, c = index + type.length; i < c; i++)
                    result = this.insert(i, type[i], $prime, args, callback, this_arg);
                return result;
            }
            
            if (typeof type === 'object') {
                // it is a control?
                var add_task = type;
                if (add_task.hasOwnProperty('__type'))
                    setParent.call(type, this, index);
                return add_task;
            }

            if (Array.isArray(args))
                args = {'': args};
            else if (!args)
                args = {};
            var parameters = {};
            
            // transfer inheritable parameters to the created object
            var this_parameters = this.parameters;
            for(var prop in this_parameters)
                if (this_parameters.hasOwnProperty(prop) && prop[0] === '/')
                    parameters[prop] = this_parameters[prop];
            
            // resolve constructor
            var __type = parse_type(type, parameters, args),
                constructor = resolve_ctr(__type, parameters);
            
            if ($prime !== undefined)
                args[''] = $prime;
            
            // load required components
            if (!constructor) {
                var parts = __type.split('.'),
                    mod_path = './modules/' + parts[0] + '/' + parts[1];
                console.log(__type + ' not loaded, try to load ' + mod_path);
                require(mod_path);
                constructor = resolve_ctr(__type, parameters);
            }
            
            if (!constructor)
                throw new TypeError('Type ' + __type + ' not registered!');
            
            // move $parameters to attributes (unsafe)
            for(var prop in parameters)
                if (parameters.hasOwnProperty(prop) && prop[0] === '$')
                    args[prop.substr(1)] = parameters[prop];
            
            // create control

            var new_control = new constructor(parameters, args);

            // reflect after creation
            new_control.raise('type');

            // set parent property
            setParent.call(new_control, this, index);

            // callback
            if (callback)
                callback.call(this_arg || this, new_control);

            return new_control;
        }
function ( index , type , /*optional*/ $prime , /*optional*/ args , /*optional*/ callback , /*optional*/ this_arg ) { if ( ! type ) return ; // normalize arguments if ( typeof $prime === 'function' ) { this_arg = args ; callback = $prime ; $prime = undefined ; args = undefined ; } else { if ( typeof $prime === 'object' && ! Array . isArray ( $prime ) ) { this_arg = callback ; callback = args ; args = $prime ; $prime = undefined ; } if ( typeof args === 'function' ) { this_arg = callback ; callback = args ; args = undefined ; } } if ( Array . isArray ( type ) ) { // collection detected var result ; for ( var i = index , c = index + type . length ; i < c ; i ++ ) result = this . insert ( i , type [ i ] , $prime , args , callback , this_arg ) ; return result ; } if ( typeof type === 'object' ) { // it is a control? var add_task = type ; if ( add_task . hasOwnProperty ( '__type' ) ) setParent . call ( type , this , index ) ; return add_task ; } if ( Array . isArray ( args ) ) args = { '' : args } ; else if ( ! args ) args = { } ; var parameters = { } ; // transfer inheritable parameters to the created object var this_parameters = this . parameters ; for ( var prop in this_parameters ) if ( this_parameters . hasOwnProperty ( prop ) && prop [ 0 ] === '/' ) parameters [ prop ] = this_parameters [ prop ] ; // resolve constructor var __type = parse_type ( type , parameters , args ) , constructor = resolve_ctr ( __type , parameters ) ; if ( $prime !== undefined ) args [ '' ] = $prime ; // load required components if ( ! constructor ) { var parts = __type . split ( '.' ) , mod_path = './modules/' + parts [ 0 ] + '/' + parts [ 1 ] ; console . log ( __type + ' not loaded, try to load ' + mod_path ) ; require ( mod_path ) ; constructor = resolve_ctr ( __type , parameters ) ; } if ( ! constructor ) throw new TypeError ( 'Type ' + __type + ' not registered!' ) ; // move $parameters to attributes (unsafe) for ( var prop in parameters ) if ( parameters . hasOwnProperty ( prop ) && prop [ 0 ] === '$' ) args [ prop . substr ( 1 ) ] = parameters [ prop ] ; // create control var new_control = new constructor ( parameters , args ) ; // reflect after creation new_control . raise ( 'type' ) ; // set parent property setParent . call ( new_control , this , index ) ; // callback if ( callback ) callback . call ( this_arg || this , new_control ) ; return new_control ; }
Create a new component and insert to the component.childs collection at the specified index.

@param {number} index Index in .childs collection.
@param {string} type Type and parameters.
@param [$prime] Prime value is a responsibility of the component. This parameter value can be of simple type or be derived from DataObject DataArray.
@param {object} [args] Arguments hash object to be passed to the component.
@param {function} [callback] The callback will be called each time after the creation of a new component.
@param {object} [this_arg] The value to be passed as the this parameter to the target function when the callback function is called.
@returns {object} Returns newly created component object.
Create a new component and insert to the component . childs collection at the specified index .