jso apis: add missing methods for Array and Object (#686)

This commit is contained in:
Ivan Hetman 2023-04-11 13:10:44 +03:00 committed by GitHub
parent 4756c9009a
commit 928a8631a8
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 12 additions and 0 deletions

View File

@ -91,6 +91,10 @@ public abstract class JSArray<T extends JSObject> implements JSArrayReader<T> {
@NoSideEffects @NoSideEffects
public static native <T extends JSObject> JSArray<T> create(int size); public static native <T extends JSObject> JSArray<T> create(int size);
@JSBody(params = "object", script = "return Array.isArray(object);")
@NoSideEffects
public static native boolean isArray(JSObject object);
@SafeVarargs @SafeVarargs
public static <S extends JSObject> JSArray<S> of(S... items) { public static <S extends JSObject> JSArray<S> of(S... items) {
JSArray<S> array = create(items.length); JSArray<S> array = create(items.length);

View File

@ -27,6 +27,14 @@ public final class JSObjects {
@NoSideEffects @NoSideEffects
public static native String[] getOwnPropertyNames(JSObject object); public static native String[] getOwnPropertyNames(JSObject object);
@JSBody(params = "object", script = "return Object.keys(object);")
@NoSideEffects
public static native String[] keys(JSObject object);
@JSBody(params = "object", script = "return Object.values(object);")
@NoSideEffects
public static native JSObject[] values(JSObject object);
@JSBody(script = "return {};") @JSBody(script = "return {};")
@NoSideEffects @NoSideEffects
public static native <T extends JSObject> T create(); public static native <T extends JSObject> T create();