fix: use Values.call instead of direct calling

This commit is contained in:
TopchetoEU 2024-01-06 17:48:10 +02:00
parent 34276d720c
commit 45f133c6b0
Signed by: topchetoeu
GPG Key ID: 6531B8583E5F6ED4
2 changed files with 2 additions and 6 deletions

View File

@ -6,7 +6,6 @@ import java.util.stream.Collectors;
import me.topchetoeu.jscript.engine.Context;
import me.topchetoeu.jscript.engine.values.ArrayValue;
import me.topchetoeu.jscript.engine.values.FunctionValue;
import me.topchetoeu.jscript.engine.values.ObjectValue;
import me.topchetoeu.jscript.engine.values.Values;
import me.topchetoeu.jscript.interop.Arguments;
@ -68,12 +67,9 @@ public class MapLib {
}
@Expose public void __forEach(Arguments args) {
var func = args.convert(0, FunctionValue.class);
var thisArg = args.get(1);
var keys = new ArrayList<>(map.keySet());
for (var el : keys) func.call(args.ctx, thisArg, map.get(el), el,this);
for (var el : keys) Values.call(args.ctx, args.get(0), args.get(1), map.get(el), el, args.self);
}
public MapLib(Context ctx, Object iterable) {

View File

@ -55,7 +55,7 @@ public class SetLib {
@Expose public void __forEach(Arguments args) {
var keys = new ArrayList<>(set);
for (var el : keys) Values.call(args.ctx, args.get(0), args.get(1), el, el, this);
for (var el : keys) Values.call(args.ctx, args.get(0), args.get(1), el, el, args.self);
}
public SetLib(Context ctx, Object iterable) {