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:
The string var.
"""
from .function import JSON_STRINGIFY, OBJECT_PROTOTYPE_TO_STRING
from .function import JSON_STRINGIFY, PROTOTYPE_TO_STRING
from .sequence import StringVar
return (
JSON_STRINGIFY.call(self).to(StringVar)
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:

View File

@ -180,4 +180,6 @@ class ArgsFunctionOperation(CachedVarOperation, FunctionVar):
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())"
)