more utility

This commit is contained in:
TopchetoEU 2024-12-25 02:53:24 +02:00
parent 277f59e54a
commit d8c18ccf17
Signed by: topchetoeu
GPG Key ID: 6531B8583E5F6ED4

View File

@ -4,6 +4,7 @@ import java.util.Arrays;
import java.util.Collection; import java.util.Collection;
import java.util.Comparator; import java.util.Comparator;
import java.util.Iterator; import java.util.Iterator;
import java.util.stream.Stream;
import me.topchetoeu.jscript.common.environment.Environment; import me.topchetoeu.jscript.common.environment.Environment;
import me.topchetoeu.jscript.runtime.values.Value; import me.topchetoeu.jscript.runtime.values.Value;
@ -72,6 +73,9 @@ public class ArrayValue extends ArrayLikeValue implements Iterable<Value> {
copyTo(res, 0, 0, size); copyTo(res, 0, 0, size);
return res; return res;
} }
public Stream<Value> stream() {
return Arrays.stream(toArray());
}
public void copyTo(Value[] arr, int sourceStart, int destStart, int count) { public void copyTo(Value[] arr, int sourceStart, int destStart, int count) {
var nullFill = Math.max(0, arr.length - size - destStart); var nullFill = Math.max(0, arr.length - size - destStart);