diff --git a/index.js b/index.js index b41a002..75b6874 100644 --- a/index.js +++ b/index.js @@ -35,6 +35,7 @@ module.exports = function serialize(obj, options) { options = {space: options}; } + var stringify = options.stringify || JSON.stringify; var functions = []; var regexps = []; var dates = []; @@ -73,9 +74,9 @@ module.exports = function serialize(obj, options) { // Creates a JSON string representation of the value. // NOTE: Node 0.12 goes into slow mode with extra JSON.stringify() args. if (options.isJSON && !options.space) { - str = JSON.stringify(obj); + str = stringify(obj); } else { - str = JSON.stringify(obj, options.isJSON ? null : replacer, options.space); + str = stringify(obj, options.isJSON ? null : replacer, options.space); } // Protects against `JSON.stringify()` returning `undefined`, by serializing