elemental2.core.JsArray Maven / Gradle / Ivy
The newest version!
/*
* Copyright 2018 Google Inc.
*
* Licensed under the Apache License, Version 2.0 (the "License"); you may not
* use this file except in compliance with the License. You may obtain a copy of
* the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
* License for the specific language governing permissions and limitations under
* the License.
*/
package elemental2.core;
import javaemul.internal.ArrayStamper;
import jsinterop.annotations.JsFunction;
import jsinterop.annotations.JsMethod;
import jsinterop.annotations.JsOverlay;
import jsinterop.annotations.JsPackage;
import jsinterop.annotations.JsType;
import jsinterop.base.Js;
import jsinterop.base.JsArrayLike;
@JsType(isNative = true, name = "Array", namespace = JsPackage.GLOBAL)
public class JsArray implements JsIterable, JsArrayLike {
@JsType(isNative = true, name = "?", namespace = JsPackage.GLOBAL)
public interface EntriesJsIteratorIterableTypeParameterArrayUnionType {
@JsOverlay
static JsArray.EntriesJsIteratorIterableTypeParameterArrayUnionType of(Object o) {
return Js.cast(o);
}
@JsOverlay
default Double asDouble() {
return Js.cast(this);
}
@JsOverlay
default T asT() {
return Js.cast(this);
}
@JsOverlay
default boolean isDouble() {
return (Object) this instanceof Double;
}
}
@JsFunction
public interface EveryCallbackFn {
Object onInvoke(T p0, int p1, JsArray p2);
@JsOverlay
default Object onInvoke(T p0, int p1, T[] p2) {
return onInvoke(p0, p1, Js.>uncheckedCast(p2));
}
}
@JsFunction
public interface FilterCallbackFn {
Object onInvoke(T p0, int p1, JsArray p2);
@JsOverlay
default Object onInvoke(T p0, int p1, T[] p2) {
return onInvoke(p0, p1, Js.>uncheckedCast(p2));
}
}
@JsFunction
public interface FindIndexPredicateFn {
boolean onInvoke(T p0, int p1, JsArray p2);
@JsOverlay
default boolean onInvoke(T p0, int p1, T[] p2) {
return onInvoke(p0, p1, Js.>uncheckedCast(p2));
}
}
@JsFunction
public interface FindPredicateFn {
boolean onInvoke(T p0, int p1, JsArray p2);
@JsOverlay
default boolean onInvoke(T p0, int p1, T[] p2) {
return onInvoke(p0, p1, Js.>uncheckedCast(p2));
}
}
@JsFunction
public interface FlatMapCallbackFn {
JsArray onInvoke(T p0, double p1, JsArrayLike p2);
@JsOverlay
default JsArray onInvoke(T p0, double p1, T[] p2) {
return onInvoke(p0, p1, Js.>uncheckedCast(p2));
}
}
@JsFunction
public interface ForEachCallbackFn {
Object onInvoke(T p0, int p1, JsArray p2);
@JsOverlay
default Object onInvoke(T p0, int p1, T[] p2) {
return onInvoke(p0, p1, Js.>uncheckedCast(p2));
}
}
@JsType(isNative = true, name = "?", namespace = JsPackage.GLOBAL)
public interface FromArrayLikeUnionType {
@JsOverlay
static JsArray.FromArrayLikeUnionType of(Object o) {
return Js.cast(o);
}
@JsOverlay
default JsArrayLike asJsArrayLike() {
return Js.cast(this);
}
@JsOverlay
default JsIterable asJsIterable() {
return Js.cast(this);
}
@JsOverlay
default String asString() {
return Js.asString(this);
}
@JsOverlay
default boolean isString() {
return (Object) this instanceof String;
}
}
@JsFunction
public interface FromMapFn {
@JsType(isNative = true, name = "?", namespace = JsPackage.GLOBAL)
public interface P0UnionType {
@JsOverlay
static JsArray.FromMapFn.P0UnionType of(Object o) {
return Js.cast(o);
}
@JsOverlay
default String asString() {
return Js.asString(this);
}
@JsOverlay
default T asT() {
return Js.cast(this);
}
@JsOverlay
default boolean isString() {
return (Object) this instanceof String;
}
}
R onInvoke(JsArray.FromMapFn.P0UnionType p0, int p1);
@JsOverlay
default R onInvoke(String p0, int p1) {
return onInvoke(Js.>uncheckedCast(p0), p1);
}
@JsOverlay
default R onInvoke(T p0, int p1) {
return onInvoke(Js.>uncheckedCast(p0), p1);
}
}
@JsFunction
public interface MapCallbackFn {
R onInvoke(T p0, int p1, JsArray p2);
@JsOverlay
default R onInvoke(T p0, int p1, T[] p2) {
return onInvoke(p0, p1, Js.>uncheckedCast(p2));
}
}
@JsFunction
public interface ReduceCallbackFn {
R onInvoke(Object p0, T p1, int p2, JsArray p3);
@JsOverlay
default R onInvoke(Object p0, T p1, int p2, T[] p3) {
return onInvoke(p0, p1, p2, Js.>uncheckedCast(p3));
}
}
@JsFunction
public interface ReduceRightCallbackFn {
R onInvoke(Object p0, T p1, int p2, JsArray p3);
@JsOverlay
default R onInvoke(Object p0, T p1, int p2, T[] p3) {
return onInvoke(p0, p1, p2, Js.>uncheckedCast(p3));
}
}
@JsFunction
public interface SomeCallbackFn {
Object onInvoke(T p0, int p1, JsArray p2);
@JsOverlay
default Object onInvoke(T p0, int p1, T[] p2) {
return onInvoke(p0, p1, Js.>uncheckedCast(p2));
}
}
@JsFunction
public interface SortCompareFn {
double onInvoke(T p0, T p1);
}
@JsOverlay
public static final JsArray asJsArray(T[] array) {
return Js.uncheckedCast(array);
}
public static native JsArray from(
JsArray.FromArrayLikeUnionType arrayLike,
JsArray.FromMapFn super T, ? extends R> mapFn,
S this_);
public static native JsArray from(
JsArray.FromArrayLikeUnionType arrayLike, JsArray.FromMapFn super T, ? extends R> mapFn);
public static native JsArray from(JsArray.FromArrayLikeUnionType arrayLike);
@JsOverlay
public static final JsArray from(
JsArrayLike arrayLike, JsArray.FromMapFn super T, ? extends R> mapFn, S this_) {
return from(Js.>uncheckedCast(arrayLike), mapFn, this_);
}
@JsOverlay
public static final JsArray from(
JsArrayLike arrayLike, JsArray.FromMapFn super T, ? extends R> mapFn) {
return from(Js.>uncheckedCast(arrayLike), mapFn);
}
@JsOverlay
public static final JsArray from(JsArrayLike arrayLike) {
return from(Js.>uncheckedCast(arrayLike));
}
@JsOverlay
public static final JsArray from(
JsIterable arrayLike, JsArray.FromMapFn super T, ? extends R> mapFn, S this_) {
return from(Js.>uncheckedCast(arrayLike), mapFn, this_);
}
@JsOverlay
public static final JsArray from(
JsIterable arrayLike, JsArray.FromMapFn super T, ? extends R> mapFn) {
return from(Js.>uncheckedCast(arrayLike), mapFn);
}
@JsOverlay
public static final JsArray from(JsIterable arrayLike) {
return from(Js.>uncheckedCast(arrayLike));
}
@JsOverlay
public static final JsArray from(
String arrayLike, JsArray.FromMapFn super T, ? extends R> mapFn, S this_) {
return from(Js.>uncheckedCast(arrayLike), mapFn, this_);
}
@JsOverlay
public static final JsArray from(
String arrayLike, JsArray.FromMapFn super T, ? extends R> mapFn) {
return from(Js.>uncheckedCast(arrayLike), mapFn);
}
@JsOverlay
public static final JsArray from(String arrayLike) {
return from(Js.>uncheckedCast(arrayLike));
}
@JsOverlay
public static final JsArray from(
T[] arrayLike, JsArray.FromMapFn super T, ? extends R> mapFn, S this_) {
return from(Js.>uncheckedCast(arrayLike), mapFn, this_);
}
@JsOverlay
public static final JsArray from(
T[] arrayLike, JsArray.FromMapFn super T, ? extends R> mapFn) {
return from(Js.>uncheckedCast(arrayLike), mapFn);
}
@JsOverlay
public static final JsArray from(T[] arrayLike) {
return from(Js.>uncheckedCast(arrayLike));
}
public static native boolean isArray(Object arr);
public static native JsArray of(T... var_args);
public int index;
public String input;
public int length;
public JsArray(T... items) {}
@JsOverlay
public final T[] asArray(T[] reference) {
return ArrayStamper.stampJavaTypeInfo(this, reference);
}
public native JsArray concat(T... items);
public native JsArray copyWithin(int target, int start, int end);
public native JsArray copyWithin(int target, int start);
public native JsIteratorIterable<
JsArray>>
entries();
public native boolean every(JsArray.EveryCallbackFn callback, S thisobj);
public native boolean every(JsArray.EveryCallbackFn callback);
public native JsArray fill(T value, int begin, int end);
public native JsArray fill(T value, int begin);
public native JsArray fill(T value);
public native JsArray filter(JsArray.FilterCallbackFn callback, S thisobj);
public native JsArray filter(JsArray.FilterCallbackFn callback);
public native T find(JsArray.FindPredicateFn predicateFn, S this_);
public native T find(JsArray.FindPredicateFn predicateFn);
public native int findIndex(JsArray.FindIndexPredicateFn predicateFn, S this_);
public native int findIndex(JsArray.FindIndexPredicateFn predicateFn);
public native JsArray flat();
public native JsArray flat(double depth);
public native JsArray flatMap(
JsArray.FlatMapCallbackFn callback, THIS thisArg);
public native JsArray flatMap(JsArray.FlatMapCallbackFn callback);
public native void forEach(JsArray.ForEachCallbackFn callback, S thisobj);
public native void forEach(JsArray.ForEachCallbackFn callback);
public native boolean includes(T searchElement, int fromIndex);
public native boolean includes(T searchElement);
public native int indexOf(T obj, int fromIndex);
public native int indexOf(T obj);
public native String join();
public native String join(Object separator);
public native JsIteratorIterable keys();
public native int lastIndexOf(T obj, int fromIndex);
public native int lastIndexOf(T obj);
public native JsArray map(JsArray.MapCallbackFn extends R, T> callback, S thisobj);
public native JsArray map(JsArray.MapCallbackFn extends R, T> callback);
public native T pop();
public native int push(T... var_args);
public native R reduce(
JsArray.ReduceCallbackFn extends R, T> callback, Object initialValue);
public native R reduce(JsArray.ReduceCallbackFn extends R, T> callback);
public native R reduceRight(
JsArray.ReduceRightCallbackFn extends R, T> callback, Object initialValue);
public native R reduceRight(JsArray.ReduceRightCallbackFn extends R, T> callback);
public native T[] reverse();
public native T shift();
public native JsArray slice();
public native JsArray slice(int begin, int end);
public native JsArray slice(int begin);
public native boolean some(JsArray.SomeCallbackFn callback, S thisobj);
public native boolean some(JsArray.SomeCallbackFn callback);
public native JsArray sort();
public native JsArray sort(JsArray.SortCompareFn super T> compareFn);
public native JsArray splice();
public native JsArray splice(int index, int howMany, T... var_args);
public native JsArray splice(int index);
public native String toSource();
@JsMethod(name = "toString")
public native String toString_();
public native int unshift(T... items);
public native JsIteratorIterable values();
}