Files
speckle-server/packages/shared/src/core/helpers/encoding.ts
T
Benjamin Ottensten 4fc1aa6d40 Support drag and drop for moving views into groups (#5353)
* Initiale drag and drop moving to group

* Update some styling

* Reenable ungrouped groups

* Support moving to ungrouped from dropdown

* Remove unneeded comments

* undo unnecessary groupId changes

* group cleanup

* clean up drag logic

---------

Co-authored-by: Kristaps Fabians Geikins <fabis94@live.com>
2025-09-02 14:09:38 +02:00

13 lines
334 B
TypeScript

// eslint-disable-next-line @typescript-eslint/no-explicit-any
export const safeParse = <Result = any>(
json: string,
guard?: (data: unknown) => data is Result
): Result | null => {
try {
const parsed = JSON.parse(json) as Result
return guard ? (guard(parsed) ? parsed : null) : parsed
} catch {
return null
}
}