UNPKG

@resk/core

Version:

An innovative TypeScript framework that empowers developers to build applications with a fully decorator-based architecture for efficient resource management. By combining the power of decorators with a resource-oriented design, DecorRes enhances code cla

1 lines 756 B
'use strict';class i{static decycle(e,a=[]){if(typeof e=="function")return;if(!e||typeof e!="object")return e;if(a.includes(e))return null;let t=a.concat([e]);return Array.isArray(e)?e.map(y=>i.decycle(y,t)):Object.fromEntries(Object.entries(e).map(([y,f])=>[y,i.decycle(f,t)]))}static stringify(e,a=false){return i.isJSON(e)?e:JSON.stringify(a!==false?i.decycle(e):e)}static isJSON(e){if(!e||typeof e!="string")return false;var a=e;return !/[^,:{}\[\]0-9.\-+Eaeflnr-u \n\r\t]/.test(a.replace(/"(\\.|[^"\\])*"/g,""))}static parse(e,a){if(!i.isJSON(e)){if(e&&typeof e=="object")for(var t in e)e[t]=i.parse(e[t],a);return e}try{if(e=JSON.parse(e,a),e&&typeof e=="object")for(var t in e)e[t]=i.parse(e[t],a);}catch(y){return e}return e}}exports.JsonHelper=i;