just native, <function>

This commit is contained in:
Chris Wanstrath 2025-10-17 12:39:14 -07:00
parent 4d2ae1c9fe
commit 93eff53a76

View File

@ -20,7 +20,7 @@ export type Value =
named: boolean,
value: '<function>'
}
| { type: 'native_function', fn: NativeFunction, value: '<native>' }
| { type: 'native', fn: NativeFunction, value: '<function>' }
export type Dict = Map<string, Value>
@ -40,10 +40,10 @@ export function toValue(v: any): Value /* throws */ {
if (v && typeof v === 'object' && 'type' in v && 'value' in v)
return v as Value
if (Array.isArray(v))
if (Array.isArray(v))
return { type: 'array', value: v.map(toValue) }
if (v instanceof RegExp)
if (v instanceof RegExp)
return { type: 'regex', value: v }
switch (typeof v) {
@ -104,8 +104,8 @@ export function toString(v: Value): string {
return 'null'
case 'function':
return '<function>'
case 'native_function':
return '<native>'
case 'native':
return '<function>'
case 'array':
return `[${v.value.map(toString).join(', ')}]`
case 'dict': {
@ -126,9 +126,7 @@ export function isEqual(a: Value, b: Value): boolean {
case 'null':
return true
case 'boolean':
return a.value === b.value
case 'number':
return a.value === b.value
case 'string':
return a.value === b.value
case 'array': {
@ -149,9 +147,8 @@ export function isEqual(a: Value, b: Value): boolean {
return String(a.value) === String(b.value)
}
case 'function':
case 'native':
return false // functions never equal
case 'native_function':
return false // native functions never equal
default:
return false
}
@ -174,9 +171,8 @@ export function fromValue(v: Value): any {
case 'regex':
return v.value
case 'function':
case 'native':
return '<function>'
case 'native_function':
return '<native>'
}
}