|
@@ -189,20 +189,18 @@ def string_strip_operation(string: Var[str]):
|
|
def string_contains_field_operation(
|
|
def string_contains_field_operation(
|
|
haystack: Var[str],
|
|
haystack: Var[str],
|
|
needle: Var[str],
|
|
needle: Var[str],
|
|
- field: VarWithDefault[str] = VarWithDefault(""),
|
|
|
|
):
|
|
):
|
|
"""Check if a string contains another string.
|
|
"""Check if a string contains another string.
|
|
|
|
|
|
Args:
|
|
Args:
|
|
haystack: The haystack.
|
|
haystack: The haystack.
|
|
needle: The needle.
|
|
needle: The needle.
|
|
- field: The field to check.
|
|
|
|
|
|
|
|
Returns:
|
|
Returns:
|
|
The string contains operation.
|
|
The string contains operation.
|
|
"""
|
|
"""
|
|
return var_operation_return(
|
|
return var_operation_return(
|
|
- js_expression=f"isTrue({field}) ? {haystack}.some(obj => obj[{field}] === {needle}) : {haystack}.some(obj => obj === {needle})",
|
|
|
|
|
|
+ js_expression=f"{haystack}.includes({needle})",
|
|
var_type=bool,
|
|
var_type=bool,
|
|
var_data=VarData(
|
|
var_data=VarData(
|
|
imports=_IS_TRUE_IMPORT,
|
|
imports=_IS_TRUE_IMPORT,
|
|
@@ -360,7 +358,7 @@ def array_pluck_operation(
|
|
The reversed array.
|
|
The reversed array.
|
|
"""
|
|
"""
|
|
return var_operation_return(
|
|
return var_operation_return(
|
|
- js_expression=f"{array}.map(e=>e?.[{field}])",
|
|
|
|
|
|
+ js_expression=f"Array.prototype.map.apply({array}, [e=>e?.[{field}]])",
|
|
var_type=List[Any],
|
|
var_type=List[Any],
|
|
)
|
|
)
|
|
|
|
|
|
@@ -378,7 +376,9 @@ def array_join_operation(
|
|
Returns:
|
|
Returns:
|
|
The joined elements.
|
|
The joined elements.
|
|
"""
|
|
"""
|
|
- return var_operation_return(js_expression=f"{array}.join({sep})", var_type=str)
|
|
|
|
|
|
+ return var_operation_return(
|
|
|
|
+ js_expression=f"Array.prototype.join.apply({array},[{sep}])", var_type=str
|
|
|
|
+ )
|
|
|
|
|
|
|
|
|
|
@var_operation
|
|
@var_operation
|
|
@@ -631,7 +631,7 @@ def array_range_operation(
|
|
The range of numbers.
|
|
The range of numbers.
|
|
"""
|
|
"""
|
|
return var_operation_return(
|
|
return var_operation_return(
|
|
- js_expression=f"range({e1}, {e2}, {step})",
|
|
|
|
|
|
+ js_expression=f"[...range({e1}, {e2}, {step})]",
|
|
var_type=List[int],
|
|
var_type=List[int],
|
|
var_data=VarData(
|
|
var_data=VarData(
|
|
imports=_RANGE_IMPORT,
|
|
imports=_RANGE_IMPORT,
|
|
@@ -769,7 +769,7 @@ def map_array_operation(
|
|
return (ReflexCallable[[], List[args[0]._var_type]], None)
|
|
return (ReflexCallable[[], List[args[0]._var_type]], None)
|
|
|
|
|
|
return var_operation_return(
|
|
return var_operation_return(
|
|
- js_expression=f"{array}.map({function})",
|
|
|
|
|
|
+ js_expression=f"Array.prototype.map.apply({array}, [{function}])",
|
|
type_computer=nary_type_computer(
|
|
type_computer=nary_type_computer(
|
|
ReflexCallable[[List[Any], ReflexCallable], List[Any]],
|
|
ReflexCallable[[List[Any], ReflexCallable], List[Any]],
|
|
ReflexCallable[[ReflexCallable], List[Any]],
|
|
ReflexCallable[[ReflexCallable], List[Any]],
|