tiptap/packages/core/src/utils/fromString.ts
2020-10-31 23:56:31 +01:00

20 lines
287 B
TypeScript

export default function fromString(value: any) {
if (typeof value !== 'string') {
return value
}
if (value.match(/^\d*(\.\d+)?$/)) {
return Number(value)
}
if (value === 'true') {
return true
}
if (value === 'false') {
return false
}
return value
}