@prefecthq/prefect-ui-library
Version:
This library is the Vue and Typescript component library for [Prefect 2](https://github.com/PrefectHQ/prefect) and [Prefect Cloud 2](https://www.prefect.io/cloud/). _The components and utilities in this project are not meant to be used independently_.
22 lines (19 loc) • 356 B
text/typescript
export type JsonSafeStringify = {
success: boolean,
value: unknown,
}
export function jsonSafeStringify(value: unknown): JsonSafeStringify {
try {
const stringified = JSON.stringify(value)
return {
success: true,
value: stringified,
}
} catch {
// silence is golden
}
return {
success: false,
value,
}
}