Files
tiptap/packages/core/src/utilities/fromString.ts
Philipp Kühn 4407d9a3d1 improve types
2021-01-28 09:50:17 +01:00

20 lines
292 B
TypeScript

export default function fromString(value: any): 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
}