lib/util.js
function (obj) {
        return _.cloneDeepWith(obj, function (value) {
            // falls back to default deepclone if object does not have explicit toJSON().
            if (value && _.isFunction(value.toJSON)) {
                return value.toJSON();
            }
        });
    }
function (obj) {
        return _.cloneDeepWith(obj, function (value) {
            // falls back to default deepclone if object does not have explicit toJSON().
            if (value && _.isFunction(value.toJSON)) {
                return value.toJSON();
            }
        });
    }
function ( obj ) { return _ . cloneDeepWith ( obj , function ( value ) { // falls back to default deepclone if object does not have explicit toJSON(). if ( value && _ . isFunction ( value . toJSON ) ) { return value . toJSON ( ) ; } } ) ; }
Creates a clone of an object, but uses the toJSON method if available.

@param {Object} obj
@returns {*}
Creates a clone of an object but uses the toJSON method if available .