add into to prelude
This commit is contained in:
parent
e4bdddc762
commit
aed7f79952
|
|
@ -161,6 +161,19 @@ export const globals = {
|
|||
return list
|
||||
},
|
||||
|
||||
into: (value: unknown, type: Value['type']) => {
|
||||
if (type === 'number') {
|
||||
const num = Number(value)
|
||||
if (isNaN(num)) throw new Error(`into: cannot convert ${value} to number`)
|
||||
return num
|
||||
} else if (type === 'string') {
|
||||
return String(value)
|
||||
} else if (type === 'boolean') {
|
||||
return Boolean(value)
|
||||
} else {
|
||||
throw new Error(`into: unsupported target type ${type}`)
|
||||
}
|
||||
},
|
||||
}
|
||||
|
||||
export const colors = {
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user