react-mixin-manager.js
function get(values, index, initiatedOnce, rtn) {
        /**
         * add the named mixin and all un-added dependencies to the return array
         * @param the mixin name
         */
        function addTo(name) {
            var indexName = name,
                match = name.match(/^([^\(]*)\s*\(([^\)]*)\)\s*/),
                params = match && match[2];
            name = match && match[1] || name;

            if (!index[indexName]) {
                if (params) {
                    // there can be no function calls here because of the regex match
                    /*jshint evil: true */
                    params = eval('[' + params + ']');
                }
                var mixin = _mixins[name],
                    checkAgain = false,
                    skip = false;

                if (mixin) {
                    if (typeof mixin === 'function') {
                        if (_initiatedOnce[name]) {
                            if (!initiatedOnce[name]) {
                                initiatedOnce[name] = [];
                                // add the placeholder so the mixin ends up in the right place
                                // we will replace all names with the appropriate mixins at the end
                                // (so we have all of the appropriate arguments)
                                mixin = name;
                            } else {
                                // but we only want to add it a single time
                                skip = true;
                            }
                            if (params) {
                                initiatedOnce[name].push(params);
                            }
                        } else {
                            mixin = mixin.apply(this, params || []);
                            checkAgain = true;
                        }
                    } else if (params) {
                        throw new Error('the mixin "' + name + '" does not support parameters');
                    }
                    get(_dependsOn[name], index, initiatedOnce, rtn);
                    get(_dependsInjected[name], index, initiatedOnce, rtn);

                    index[indexName] = true;
                    if (checkAgain) {
                        get([mixin], index, initiatedOnce, rtn);
                    } else if (!skip) {
                        checkForInlineMixins(mixin, rtn);
                        rtn.push(mixin);
                    }

                } else {
                    throw new Error('invalid mixin "' + name + '"');
                }
            }
        }

        // if the mixin has a "mixins" attribute, clone and add those dependencies first
        function checkForInlineMixins(mixin, rtn) {
            if (mixin.mixins) {
                get(mixin.mixins, index, initiatedOnce, rtn);
            }
        }

        function handleMixin(mixin) {
            if (mixin) {
                if (Array.isArray(mixin)) {
                    // flatten it out
                    get(mixin, index, initiatedOnce, rtn);
                } else if (typeof mixin === 'string') {
                    // add the named mixin and all of it's dependencies
                    addTo(mixin);
                } else {
                    checkForInlineMixins(mixin, rtn);

                    // just add the mixin normally
                    rtn.push(mixin);
                }
            }
        }

        if (Array.isArray(values)) {
            for (var i = 0; i < values.length; i++) {
                handleMixin(values[i]);
            }
        } else {
            handleMixin(values);
        }
    }
function get(values, index, initiatedOnce, rtn) {
        /**
         * add the named mixin and all un-added dependencies to the return array
         * @param the mixin name
         */
        function addTo(name) {
            var indexName = name,
                match = name.match(/^([^\(]*)\s*\(([^\)]*)\)\s*/),
                params = match && match[2];
            name = match && match[1] || name;

            if (!index[indexName]) {
                if (params) {
                    // there can be no function calls here because of the regex match
                    /*jshint evil: true */
                    params = eval('[' + params + ']');
                }
                var mixin = _mixins[name],
                    checkAgain = false,
                    skip = false;

                if (mixin) {
                    if (typeof mixin === 'function') {
                        if (_initiatedOnce[name]) {
                            if (!initiatedOnce[name]) {
                                initiatedOnce[name] = [];
                                // add the placeholder so the mixin ends up in the right place
                                // we will replace all names with the appropriate mixins at the end
                                // (so we have all of the appropriate arguments)
                                mixin = name;
                            } else {
                                // but we only want to add it a single time
                                skip = true;
                            }
                            if (params) {
                                initiatedOnce[name].push(params);
                            }
                        } else {
                            mixin = mixin.apply(this, params || []);
                            checkAgain = true;
                        }
                    } else if (params) {
                        throw new Error('the mixin "' + name + '" does not support parameters');
                    }
                    get(_dependsOn[name], index, initiatedOnce, rtn);
                    get(_dependsInjected[name], index, initiatedOnce, rtn);

                    index[indexName] = true;
                    if (checkAgain) {
                        get([mixin], index, initiatedOnce, rtn);
                    } else if (!skip) {
                        checkForInlineMixins(mixin, rtn);
                        rtn.push(mixin);
                    }

                } else {
                    throw new Error('invalid mixin "' + name + '"');
                }
            }
        }

        // if the mixin has a "mixins" attribute, clone and add those dependencies first
        function checkForInlineMixins(mixin, rtn) {
            if (mixin.mixins) {
                get(mixin.mixins, index, initiatedOnce, rtn);
            }
        }

        function handleMixin(mixin) {
            if (mixin) {
                if (Array.isArray(mixin)) {
                    // flatten it out
                    get(mixin, index, initiatedOnce, rtn);
                } else if (typeof mixin === 'string') {
                    // add the named mixin and all of it's dependencies
                    addTo(mixin);
                } else {
                    checkForInlineMixins(mixin, rtn);

                    // just add the mixin normally
                    rtn.push(mixin);
                }
            }
        }

        if (Array.isArray(values)) {
            for (var i = 0; i < values.length; i++) {
                handleMixin(values[i]);
            }
        } else {
            handleMixin(values);
        }
    }
function get ( values , index , initiatedOnce , rtn ) { /**
         * add the named mixin and all un-added dependencies to the return array
         * @param the mixin name
         */ function addTo ( name ) { var indexName = name , match = name . match ( / ^([^\(]*)\s*\(([^\)]*)\)\s* / ) , params = match && match [ 2 ] ; name = match && match [ 1 ] || name ; if ( ! index [ indexName ] ) { if ( params ) { // there can be no function calls here because of the regex match /*jshint evil: true */ params = eval ( '[' + params + ']' ) ; } var mixin = _mixins [ name ] , checkAgain = false , skip = false ; if ( mixin ) { if ( typeof mixin === 'function' ) { if ( _initiatedOnce [ name ] ) { if ( ! initiatedOnce [ name ] ) { initiatedOnce [ name ] = [ ] ; // add the placeholder so the mixin ends up in the right place // we will replace all names with the appropriate mixins at the end // (so we have all of the appropriate arguments) mixin = name ; } else { // but we only want to add it a single time skip = true ; } if ( params ) { initiatedOnce [ name ] . push ( params ) ; } } else { mixin = mixin . apply ( this , params || [ ] ) ; checkAgain = true ; } } else if ( params ) { throw new Error ( 'the mixin "' + name + '" does not support parameters' ) ; } get ( _dependsOn [ name ] , index , initiatedOnce , rtn ) ; get ( _dependsInjected [ name ] , index , initiatedOnce , rtn ) ; index [ indexName ] = true ; if ( checkAgain ) { get ( [ mixin ] , index , initiatedOnce , rtn ) ; } else if ( ! skip ) { checkForInlineMixins ( mixin , rtn ) ; rtn . push ( mixin ) ; } } else { throw new Error ( 'invalid mixin "' + name + '"' ) ; } } } // if the mixin has a "mixins" attribute, clone and add those dependencies first function checkForInlineMixins ( mixin , rtn ) { if ( mixin . mixins ) { get ( mixin . mixins , index , initiatedOnce , rtn ) ; } } function handleMixin ( mixin ) { if ( mixin ) { if ( Array . isArray ( mixin ) ) { // flatten it out get ( mixin , index , initiatedOnce , rtn ) ; } else if ( typeof mixin === 'string' ) { // add the named mixin and all of it's dependencies addTo ( mixin ) ; } else { checkForInlineMixins ( mixin , rtn ) ; // just add the mixin normally rtn . push ( mixin ) ; } } } if ( Array . isArray ( values ) ) { for ( var i = 0 ; i < values . length ; i ++ ) { handleMixin ( values [ i ] ) ; } } else { handleMixin ( values ) ; } }
return the normalized mixin list
@param values {Array} list of mixin entries
@param index {Object} hash which contains a truthy value for all named mixins that have been added
@param initiatedOnce {Object} hash which collects mixins and their parameters that should be initiated once
@param rtn {Array} the normalized return array
return the normalized mixin list