Devendra174's picture
Upload folder using huggingface_hub
1e92f2d verified
export function circularReferenceSafeJSONStringify( json, space ) {
try {
let cache = [];
const str = JSON.stringify(
json,
function ( key, value ) {
if ( typeof value === 'object' && value !== null ) {
if ( cache.indexOf( value ) !== -1 ) {
return 'Circular reference';
}
cache.push( value );
}
return value;
},
space
);
cache = null;
return str;
} catch ( e ) {
return 'Error: ' + e.message;
}
}