split helpers and utilities
This commit is contained in:
19
packages/core/src/utilities/fromString.ts
Normal file
19
packages/core/src/utilities/fromString.ts
Normal file
@@ -0,0 +1,19 @@
|
||||
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
|
||||
}
|
||||
Reference in New Issue
Block a user