2
0
Files
bot/packages/variables/parseGuessedTypeFromString.ts

13 lines
275 B
TypeScript
Raw Normal View History

export const parseGuessedTypeFromString = (value: string): unknown => {
if (value === 'undefined') return undefined
return safeJsonParse(value)
}
const safeJsonParse = (value: string): unknown => {
try {
return JSON.parse(value)
} catch {
return value
}
}