cordova/mpdjs/jsbuild/r.js
function (obj, options, totalIndent) {
            var startBrace, endBrace, nextIndent,
                first = true,
                value = '',
                lineReturn = options.lineReturn,
                indent = options.indent,
                outDentRegExp = options.outDentRegExp,
                quote = options.quote || '"';

            totalIndent = totalIndent || '';
            nextIndent = totalIndent + indent;

            if (obj === null) {
                value = 'null';
            } else if (obj === undefined) {
                value = 'undefined';
            } else if (typeof obj === 'number' || typeof obj === 'boolean') {
                value = obj;
            } else if (typeof obj === 'string') {
                //Use double quotes in case the config may also work as JSON.
                value = quote + lang.jsEscape(obj) + quote;
            } else if (lang.isArray(obj)) {
                lang.each(obj, function (item, i) {
                    value += (i !== 0 ? ',' + lineReturn : '' ) +
                        nextIndent +
                        transform.objectToString(item,
                                                 options,
                                                 nextIndent);
                });

                startBrace = '[';
                endBrace = ']';
            } else if (lang.isFunction(obj) || lang.isRegExp(obj)) {
                //The outdent regexp just helps pretty up the conversion
                //just in node. Rhino strips comments and does a different
                //indent scheme for Function toString, so not really helpful
                //there.
                value = obj.toString().replace(outDentRegExp, '$1');
            } else {
                //An object
                lang.eachProp(obj, function (v, prop) {
                    value += (first ? '': ',' + lineReturn) +
                        nextIndent +
                        (keyRegExp.test(prop) ? prop : quote + lang.jsEscape(prop) + quote )+
                        ': ' +
                        transform.objectToString(v,
                                                 options,
                                                 nextIndent);
                    first = false;
                });
                startBrace = '{';
                endBrace = '}';
            }

            if (startBrace) {
                value = startBrace +
                        lineReturn +
                        value +
                        lineReturn + totalIndent +
                        endBrace;
            }

            return value;
        }
function (obj, options, totalIndent) {
            var startBrace, endBrace, nextIndent,
                first = true,
                value = '',
                lineReturn = options.lineReturn,
                indent = options.indent,
                outDentRegExp = options.outDentRegExp,
                quote = options.quote || '"';

            totalIndent = totalIndent || '';
            nextIndent = totalIndent + indent;

            if (obj === null) {
                value = 'null';
            } else if (obj === undefined) {
                value = 'undefined';
            } else if (typeof obj === 'number' || typeof obj === 'boolean') {
                value = obj;
            } else if (typeof obj === 'string') {
                //Use double quotes in case the config may also work as JSON.
                value = quote + lang.jsEscape(obj) + quote;
            } else if (lang.isArray(obj)) {
                lang.each(obj, function (item, i) {
                    value += (i !== 0 ? ',' + lineReturn : '' ) +
                        nextIndent +
                        transform.objectToString(item,
                                                 options,
                                                 nextIndent);
                });

                startBrace = '[';
                endBrace = ']';
            } else if (lang.isFunction(obj) || lang.isRegExp(obj)) {
                //The outdent regexp just helps pretty up the conversion
                //just in node. Rhino strips comments and does a different
                //indent scheme for Function toString, so not really helpful
                //there.
                value = obj.toString().replace(outDentRegExp, '$1');
            } else {
                //An object
                lang.eachProp(obj, function (v, prop) {
                    value += (first ? '': ',' + lineReturn) +
                        nextIndent +
                        (keyRegExp.test(prop) ? prop : quote + lang.jsEscape(prop) + quote )+
                        ': ' +
                        transform.objectToString(v,
                                                 options,
                                                 nextIndent);
                    first = false;
                });
                startBrace = '{';
                endBrace = '}';
            }

            if (startBrace) {
                value = startBrace +
                        lineReturn +
                        value +
                        lineReturn + totalIndent +
                        endBrace;
            }

            return value;
        }
function ( obj , options , totalIndent ) { var startBrace , endBrace , nextIndent , first = true , value = '' , lineReturn = options . lineReturn , indent = options . indent , outDentRegExp = options . outDentRegExp , quote = options . quote || '"' ; totalIndent = totalIndent || '' ; nextIndent = totalIndent + indent ; if ( obj === null ) { value = 'null' ; } else if ( obj === undefined ) { value = 'undefined' ; } else if ( typeof obj === 'number' || typeof obj === 'boolean' ) { value = obj ; } else if ( typeof obj === 'string' ) { //Use double quotes in case the config may also work as JSON. value = quote + lang . jsEscape ( obj ) + quote ; } else if ( lang . isArray ( obj ) ) { lang . each ( obj , function ( item , i ) { value += ( i !== 0 ? ',' + lineReturn : '' ) + nextIndent + transform . objectToString ( item , options , nextIndent ) ; } ) ; startBrace = '[' ; endBrace = ']' ; } else if ( lang . isFunction ( obj ) || lang . isRegExp ( obj ) ) { //The outdent regexp just helps pretty up the conversion //just in node. Rhino strips comments and does a different //indent scheme for Function toString, so not really helpful //there. value = obj . toString ( ) . replace ( outDentRegExp , '$1' ) ; } else { //An object lang . eachProp ( obj , function ( v , prop ) { value += ( first ? '' : ',' + lineReturn ) + nextIndent + ( keyRegExp . test ( prop ) ? prop : quote + lang . jsEscape ( prop ) + quote ) + ': ' + transform . objectToString ( v , options , nextIndent ) ; first = false ; } ) ; startBrace = '{' ; endBrace = '}' ; } if ( startBrace ) { value = startBrace + lineReturn + value + lineReturn + totalIndent + endBrace ; } return value ; }
Tries converting a JS object to a string. This will likely suck, and
is tailored to the type of config expected in a loader config call.
So, hasOwnProperty fields, strings, numbers, arrays and functions,
no weird recursively referenced stuff.
@param  {Object} obj        the object to convert
@param  {Object} options    options object with the following values:
{String} indent     the indentation to use for each level
{String} lineReturn the type of line return to use
{outDentRegExp} outDentRegExp the regexp to use to outdent functions
{String} quote      the quote type to use, ' or ". Optional. Default is "
@param  {String} totalIndent the total indent to print for this level
@return {String}            a string representation of the object.
Tries converting a JS object to a string . This will likely suck and is tailored to the type of config expected in a loader config call . So hasOwnProperty fields strings numbers arrays and functions no weird recursively referenced stuff .