just native, <function>
This commit is contained in:
parent
4d2ae1c9fe
commit
93eff53a76
14
src/value.ts
14
src/value.ts
|
|
@ -20,7 +20,7 @@ export type Value =
|
||||||
named: boolean,
|
named: boolean,
|
||||||
value: '<function>'
|
value: '<function>'
|
||||||
}
|
}
|
||||||
| { type: 'native_function', fn: NativeFunction, value: '<native>' }
|
| { type: 'native', fn: NativeFunction, value: '<function>' }
|
||||||
|
|
||||||
export type Dict = Map<string, Value>
|
export type Dict = Map<string, Value>
|
||||||
|
|
||||||
|
|
@ -104,8 +104,8 @@ export function toString(v: Value): string {
|
||||||
return 'null'
|
return 'null'
|
||||||
case 'function':
|
case 'function':
|
||||||
return '<function>'
|
return '<function>'
|
||||||
case 'native_function':
|
case 'native':
|
||||||
return '<native>'
|
return '<function>'
|
||||||
case 'array':
|
case 'array':
|
||||||
return `[${v.value.map(toString).join(', ')}]`
|
return `[${v.value.map(toString).join(', ')}]`
|
||||||
case 'dict': {
|
case 'dict': {
|
||||||
|
|
@ -126,9 +126,7 @@ export function isEqual(a: Value, b: Value): boolean {
|
||||||
case 'null':
|
case 'null':
|
||||||
return true
|
return true
|
||||||
case 'boolean':
|
case 'boolean':
|
||||||
return a.value === b.value
|
|
||||||
case 'number':
|
case 'number':
|
||||||
return a.value === b.value
|
|
||||||
case 'string':
|
case 'string':
|
||||||
return a.value === b.value
|
return a.value === b.value
|
||||||
case 'array': {
|
case 'array': {
|
||||||
|
|
@ -149,9 +147,8 @@ export function isEqual(a: Value, b: Value): boolean {
|
||||||
return String(a.value) === String(b.value)
|
return String(a.value) === String(b.value)
|
||||||
}
|
}
|
||||||
case 'function':
|
case 'function':
|
||||||
|
case 'native':
|
||||||
return false // functions never equal
|
return false // functions never equal
|
||||||
case 'native_function':
|
|
||||||
return false // native functions never equal
|
|
||||||
default:
|
default:
|
||||||
return false
|
return false
|
||||||
}
|
}
|
||||||
|
|
@ -174,9 +171,8 @@ export function fromValue(v: Value): any {
|
||||||
case 'regex':
|
case 'regex':
|
||||||
return v.value
|
return v.value
|
||||||
case 'function':
|
case 'function':
|
||||||
|
case 'native':
|
||||||
return '<function>'
|
return '<function>'
|
||||||
case 'native_function':
|
|
||||||
return '<native>'
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue
Block a user