lib/hashomatic.js
function (value, replacer, space) {

            // The stringify method takes a value and an optional replacer, and an optional
            // space parameter, and returns a JSON text. The replacer can be a function
            // that can replace values, or an array of strings that will select the keys.
            // A default replacer method can be provided. Use of the space parameter can
            // produce text that is more easily readable.

            var i;
            hashomatic._gap = '';
            hashomatic._indent = '';

            // If the space parameter is a number, make an indent string containing that
            // many spaces.

            if (typeof space === 'number') {
                for (i = 0; i < space; i += 1) {
                    hashomatic._indent += ' ';
                }

                // If the space parameter is a string, it will be used as the indent string.

            }
            else if (typeof space === 'string') {
                hashomatic._indent = space;
            }

            // If there is a replacer, it must be a function or an array.
            // Otherwise, throw an error.

            hashomatic._rep = replacer;
            if (replacer && typeof replacer !== 'function' &&
                (typeof replacer !== 'object' ||
                    typeof replacer.length !== 'number')) {
                throw new Error('JSON.stringify');
            }

            // Make a fake root object containing our value under the key of ''.
            // Return the result of stringifying the value.

            return hashomatic._str('', {'': value});
        }
function (value, replacer, space) {

            // The stringify method takes a value and an optional replacer, and an optional
            // space parameter, and returns a JSON text. The replacer can be a function
            // that can replace values, or an array of strings that will select the keys.
            // A default replacer method can be provided. Use of the space parameter can
            // produce text that is more easily readable.

            var i;
            hashomatic._gap = '';
            hashomatic._indent = '';

            // If the space parameter is a number, make an indent string containing that
            // many spaces.

            if (typeof space === 'number') {
                for (i = 0; i < space; i += 1) {
                    hashomatic._indent += ' ';
                }

                // If the space parameter is a string, it will be used as the indent string.

            }
            else if (typeof space === 'string') {
                hashomatic._indent = space;
            }

            // If there is a replacer, it must be a function or an array.
            // Otherwise, throw an error.

            hashomatic._rep = replacer;
            if (replacer && typeof replacer !== 'function' &&
                (typeof replacer !== 'object' ||
                    typeof replacer.length !== 'number')) {
                throw new Error('JSON.stringify');
            }

            // Make a fake root object containing our value under the key of ''.
            // Return the result of stringifying the value.

            return hashomatic._str('', {'': value});
        }
function ( value , replacer , space ) { // The stringify method takes a value and an optional replacer, and an optional // space parameter, and returns a JSON text. The replacer can be a function // that can replace values, or an array of strings that will select the keys. // A default replacer method can be provided. Use of the space parameter can // produce text that is more easily readable. var i ; hashomatic . _gap = '' ; hashomatic . _indent = '' ; // If the space parameter is a number, make an indent string containing that // many spaces. if ( typeof space === 'number' ) { for ( i = 0 ; i < space ; i += 1 ) { hashomatic . _indent += ' ' ; } // If the space parameter is a string, it will be used as the indent string. } else if ( typeof space === 'string' ) { hashomatic . _indent = space ; } // If there is a replacer, it must be a function or an array. // Otherwise, throw an error. hashomatic . _rep = replacer ; if ( replacer && typeof replacer !== 'function' && ( typeof replacer !== 'object' || typeof replacer . length !== 'number' ) ) { throw new Error ( 'JSON.stringify' ) ; } // Make a fake root object containing our value under the key of ''. // Return the result of stringifying the value. return hashomatic . _str ( '' , { '' : value } ) ; }
If the JSON object does not yet have a stringify method, give it one.
If the JSON object does not yet have a stringify method give it one .