mirror of
https://github.com/robertkrimen/otto
synced 2025-10-12 20:27:30 +08:00

Enable more linters, address the issues and do a major naming refactor to use golang lower camelCase identifiers for types, functions, methods and variable names. Also: * Clean up inline generation so it doesn't rely on temporary variables. * Remove unused functions generated by inline.pl.
21 lines
494 B
Go
21 lines
494 B
Go
package otto
|
|
|
|
func toNumberPrimitive(value Value) Value {
|
|
return toPrimitive(value, defaultValueHintNumber)
|
|
}
|
|
|
|
func toPrimitiveValue(value Value) Value {
|
|
return toPrimitive(value, defaultValueNoHint)
|
|
}
|
|
|
|
func toPrimitive(value Value, hint defaultValueHint) Value {
|
|
switch value.kind {
|
|
case valueNull, valueUndefined, valueNumber, valueString, valueBoolean:
|
|
return value
|
|
case valueObject:
|
|
return value.object().DefaultValue(hint)
|
|
default:
|
|
panic(hereBeDragons(value.kind, value))
|
|
}
|
|
}
|