tiptap/packages/core/src/utils/fromString.ts

16 lines
230 B
TypeScript
Raw Normal View History

2020-11-01 06:35:30 +08:00
export default function fromString(value: any) {
if (value.match(/^\d*(\.\d+)?$/)) {
return Number(value)
}
if (value === 'true') {
return true
}
if (value === 'false') {
return false
}
return value
}