mirror of
https://github.com/ueberdosis/tiptap.git
synced 2024-12-23 00:27:49 +08:00
20 lines
287 B
TypeScript
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
|
|
}
|