tiptap/packages/core/src/utilities/fromString.ts
2020-11-30 09:42:53 +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
}