fix prototype to string

This commit is contained in:
Khaleel Al-Adhami 2024-10-15 10:43:43 -07:00
parent 7f3342e6c9
commit a646e16f7b
2 changed files with 5 additions and 3 deletions

View File

@ -929,13 +929,13 @@ class Var(Generic[VAR_TYPE]):
Returns: Returns:
The string var. The string var.
""" """
from .function import JSON_STRINGIFY, OBJECT_PROTOTYPE_TO_STRING from .function import JSON_STRINGIFY, PROTOTYPE_TO_STRING
from .sequence import StringVar from .sequence import StringVar
return ( return (
JSON_STRINGIFY.call(self).to(StringVar) JSON_STRINGIFY.call(self).to(StringVar)
if use_json if use_json
else OBJECT_PROTOTYPE_TO_STRING.call(self).to(StringVar) else PROTOTYPE_TO_STRING.call(self).to(StringVar)
) )
def as_ref(self) -> Var: def as_ref(self) -> Var:

View File

@ -180,4 +180,6 @@ class ArgsFunctionOperation(CachedVarOperation, FunctionVar):
JSON_STRINGIFY = FunctionStringVar.create("JSON.stringify") JSON_STRINGIFY = FunctionStringVar.create("JSON.stringify")
OBJECT_PROTOTYPE_TO_STRING = FunctionStringVar.create("Object.prototype.toString") PROTOTYPE_TO_STRING = FunctionStringVar.create(
"((__to_string) => __to_string.toString())"
)