Submit
Path:
~
/
/
usr
/
share
/
grafana
/
public
/
app
/
features
/
inspector
/
utils
/
File Content:
utils.ts
import { AppEvents } from '@grafana/data'; import appEvents from 'app/core/app_events'; export function getPrettyJSON(obj: unknown): string { let r = ''; try { r = JSON.stringify(obj, getCircularReplacer(), 2); } catch (e) { if ( e instanceof Error && (e.toString().includes('RangeError') || e.toString().includes('allocation size overflow')) ) { appEvents.emit(AppEvents.alertError, [e.toString(), 'Cannot display JSON, the object is too big.']); } else { appEvents.emit(AppEvents.alertError, [e instanceof Error ? e.toString() : e]); } } return r; } function getCircularReplacer() { const seen = new WeakSet(); return (key: string, value: unknown) => { if (key === '__dataContext' || key === '__sceneObject') { return 'Filtered out in JSON serialization'; } if (typeof value === 'object' && value !== null) { if (seen.has(value)) { return; } seen.add(value); } return value; }; }
Submit
FILE
FOLDER
INFO
Name
Size
Permission
Action
download.test.ts
3641 bytes
0644
download.ts
3214 bytes
0644
utils.ts
998 bytes
0644
N4ST4R_ID | Naxtarrr