fix: use Values.call instead of direct calling
This commit is contained in:
parent
34276d720c
commit
45f133c6b0
@ -6,7 +6,6 @@ import java.util.stream.Collectors;
|
|||||||
|
|
||||||
import me.topchetoeu.jscript.engine.Context;
|
import me.topchetoeu.jscript.engine.Context;
|
||||||
import me.topchetoeu.jscript.engine.values.ArrayValue;
|
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.ObjectValue;
|
||||||
import me.topchetoeu.jscript.engine.values.Values;
|
import me.topchetoeu.jscript.engine.values.Values;
|
||||||
import me.topchetoeu.jscript.interop.Arguments;
|
import me.topchetoeu.jscript.interop.Arguments;
|
||||||
@ -68,12 +67,9 @@ public class MapLib {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Expose public void __forEach(Arguments args) {
|
@Expose public void __forEach(Arguments args) {
|
||||||
var func = args.convert(0, FunctionValue.class);
|
|
||||||
var thisArg = args.get(1);
|
|
||||||
|
|
||||||
var keys = new ArrayList<>(map.keySet());
|
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) {
|
public MapLib(Context ctx, Object iterable) {
|
||||||
|
@ -55,7 +55,7 @@ public class SetLib {
|
|||||||
@Expose public void __forEach(Arguments args) {
|
@Expose public void __forEach(Arguments args) {
|
||||||
var keys = new ArrayList<>(set);
|
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) {
|
public SetLib(Context ctx, Object iterable) {
|
||||||
|
Loading…
Reference in New Issue
Block a user