T - the type of the array elements.@JsType(name="Array",
isNative=true,
namespace="<global>")
public class JsArray<T>
extends java.lang.Object
implements JsIterable<T>, jsinterop.base.JsArrayLike<T>
| Modifier and Type | Class and Description |
|---|---|
static interface |
JsArray.Comparator<T> |
static interface |
JsArray.Converter<T,R> |
static class |
JsArray.Entry<T> |
static interface |
JsArray.FlatMap<S,T> |
static interface |
JsArray.FlatMap2<S,T> |
static interface |
JsArray.FlatMap3<S,T> |
static interface |
JsArray.ForEachCallback<T> |
static interface |
JsArray.ForEachCallback2<T> |
static interface |
JsArray.ForEachCallback3<T> |
static interface |
JsArray.Map<R,T> |
static interface |
JsArray.Map2<R,T> |
static interface |
JsArray.Map3<R,T> |
static interface |
JsArray.Predicate<T> |
static interface |
JsArray.Predicate2<T> |
static interface |
JsArray.Predicate3<T> |
static interface |
JsArray.Reduce<R,T> |
static interface |
JsArray.Reduce2<R,T> |
static interface |
JsArray.Reduce3<R,T> |
| Modifier and Type | Field and Description |
|---|---|
int |
length
The length property of an object which is an instance of type Array sets or returns the number of elements in that array.
|
| Constructor and Description |
|---|
JsArray(T... items)
The Array() constructor is used to create Array objects.
|
| Modifier and Type | Method and Description |
|---|---|
T[] |
asArray(T[] reference)
Convert this JsArray to a native "java" array.
|
static <T> JsArray<T> |
asJsArray(T[] array)
Cast the specified array to a JsArray instance.
|
JsArray<T> |
concat(T... items)
The concat() method is used to merge two or more arrays.
|
JsArray<T> |
copyWithin(int target,
int start)
The copyWithin() method shallow copies part of an array to another location in the same array and returns it without modifying its length.
|
JsArray<T> |
copyWithin(int target,
int start,
int end)
The copyWithin() method shallow copies part of an array to another location in the same array and returns it without modifying its length.
|
JsIteratorIterable<JsArray<JsArray.Entry<T>>> |
entries()
The entries() method returns a new Array Iterator object that contains the key/value pairs for each index in the array.
|
boolean |
every(JsArray.Predicate<T> predicate)
The every() method tests whether all elements in the array pass the test implemented by the provided function.
|
boolean |
every(JsArray.Predicate2<T> predicate)
The every() method tests whether all elements in the array pass the test implemented by the provided function.
|
boolean |
every(JsArray.Predicate3<T> predicate)
The every() method tests whether all elements in the array pass the test implemented by the provided function.
|
JsArray<T> |
fill(T value)
The fill() method changes all elements in an array to a static value.
|
JsArray<T> |
fill(T value,
int begin)
The fill() method changes all elements in an array to a static value, from a start index to the end of the array.
|
JsArray<T> |
fill(T value,
int begin,
int end)
The fill() method changes all elements in an array to a static value, from a start index to an end index.
|
JsArray<T> |
filter(JsArray.Predicate<T> predicate)
The filter() method creates a new array with all elements that pass the test implemented by the provided function.
|
JsArray<T> |
filter(JsArray.Predicate2<T> predicate)
The filter() method creates a new array with all elements that pass the test implemented by the provided function.
|
JsArray<T> |
filter(JsArray.Predicate3<T> predicate)
The filter() method creates a new array with all elements that pass the test implemented by the provided function.
|
T |
find(JsArray.Predicate<T> predicate)
The find() method returns the value of the first element in the provided array that satisfies the provided testing function.
|
T |
find(JsArray.Predicate2<T> predicate)
The find() method returns the value of the first element in the provided array that satisfies the provided testing function.
|
T |
find(JsArray.Predicate3<T> predicate)
The find() method returns the value of the first element in the provided array that satisfies the provided testing function.
|
int |
findIndex(JsArray.Predicate<T> predicate)
The findIndex() method returns the index of the first element in the array that satisfies the provided testing function.
|
int |
findIndex(JsArray.Predicate2<T> predicate)
The findIndex() method returns the index of the first element in the array that satisfies the provided testing function.
|
int |
findIndex(JsArray.Predicate3<T> predicate)
The findIndex() method returns the index of the first element in the array that satisfies the provided testing function.
|
<S> JsArray<S> |
flat()
The flat() method creates a new array with all sub-array elements concatenated into it recursively up to the specified depth.
|
<S> JsArray<S> |
flat(double depth)
The flat() method creates a new array with all sub-array elements concatenated into it recursively up to the specified depth.
|
<S> JsArray<S> |
flatMap(JsArray.FlatMap<S,T> callback)
The flatMap() method returns a new array formed by applying a given callback function to each element of the array, and then flattening the result by one level.
|
<S> JsArray<S> |
flatMap(JsArray.FlatMap2<S,T> callback)
The flatMap() method returns a new array formed by applying a given callback function to each element of the array, and then flattening the result by one level.
|
<S> JsArray<S> |
flatMap(JsArray.FlatMap3<S,T> callback)
The flatMap() method returns a new array formed by applying a given callback function to each element of the array, and then flattening the result by one level.
|
void |
forEach(JsArray.ForEachCallback<T> callback)
The forEach() method executes a provided function once for each array element.
|
void |
forEach(JsArray.ForEachCallback2<T> callback)
The forEach() method executes a provided function once for each array element.
|
void |
forEach(JsArray.ForEachCallback3<T> callback)
The forEach() method executes a provided function once for each array element.
|
static <T,R> JsArray<R> |
from(jsinterop.base.JsArrayLike<T> arrayLike)
The Array.from() static method creates a new, shallow-copied Array instance from an array-like or iterable object.
|
static <T,R> JsArray<R> |
from(jsinterop.base.JsArrayLike<T> arrayLike,
JsArray.Converter<? super T,? extends R> mapFn)
The Array.from() static method creates a new, shallow-copied Array instance from an array-like or iterable object.
|
static <T,R> JsArray<R> |
from(JsIterable<T> arrayLike)
The Array.from() static method creates a new, shallow-copied Array instance from an array-like or iterable object.
|
static <T,R> JsArray<R> |
from(JsIterable<T> arrayLike,
JsArray.Converter<? super T,? extends R> mapFn)
The Array.from() static method creates a new, shallow-copied Array instance from an array-like or iterable object.
|
static <T,R> JsArray<R> |
from(T[] arrayLike)
The Array.from() static method creates a new, shallow-copied Array instance from an array-like or iterable object.
|
static <T,R> JsArray<R> |
from(T[] arrayLike,
JsArray.Converter<? super T,? extends R> mapFn)
The Array.from() static method creates a new, shallow-copied Array instance from an array-like or iterable object.
|
boolean |
includes(T searchElement)
The includes() method determines whether an array includes a certain value among its entries, returning true or false as appropriate.
|
boolean |
includes(T searchElement,
int fromIndex)
The includes() method determines whether an array includes a certain value among its entries, returning true or false as appropriate.
|
int |
indexOf(T searchElement)
The indexOf() method returns the first index at which a given element can be found in the array, or -1 if it is not present.
|
int |
indexOf(T searchElement,
int fromIndex)
The indexOf() method returns the first index at which a given element can be found in the array, or -1 if it is not present.
|
static boolean |
isArray(java.lang.Object value)
The Array.isArray() method determines whether the passed value is an Array.
|
java.lang.String |
join()
The join() method creates and returns a new string by concatenating all of the elements in an array (or an array-like object), separated by commas.
|
java.lang.String |
join(java.lang.String separator)
The join() method creates and returns a new string by concatenating all of the elements in an array (or an array-like object), separated by the specified separator string.
|
JsIteratorIterable<java.lang.Double> |
keys()
The keys() method returns a new Array Iterator object that contains the keys for each index in the array.
|
int |
lastIndexOf(T searchElement)
The lastIndexOf() method returns the last index at which a given element can be found in the array, or -1 if it is not present.
|
int |
lastIndexOf(T searchElement,
int fromIndex)
The lastIndexOf() method returns the last index at which a given element can be found in the array, or -1 if it is not present.
|
<R> JsArray<R> |
map(JsArray.Map<? extends R,T> callback)
The map() method creates a new array populated with the results of calling a provided function on every element in the calling array.
|
<R> JsArray<R> |
map(JsArray.Map2<? extends R,T> callback)
The map() method creates a new array populated with the results of calling a provided function on every element in the calling array.
|
<R> JsArray<R> |
map(JsArray.Map3<? extends R,T> callback)
The map() method creates a new array populated with the results of calling a provided function on every element in the calling array.
|
static <T> JsArray<T> |
of(T... var_args)
The Array.of() method creates a new Array instance from a variable number of arguments, regardless of number or type of the arguments.
|
T |
pop()
The pop() method removes the last element from an array and returns that element.
|
int |
push(T... elements)
The push() method adds one or more elements to the end of an array and returns the new length of the array.
|
<R> R |
reduce(JsArray.Reduce<? extends R,T> reducer)
The reduce() method executes a reducer function (that you provide) on each element of the array, resulting in single output value.
|
<R> R |
reduce(JsArray.Reduce<? extends R,T> reducer,
R initialValue)
The reduce() method executes a reducer function (that you provide) on each element of the array, resulting in single output value.
|
<R> R |
reduce(JsArray.Reduce2<? extends R,T> reducer)
The reduce() method executes a reducer function (that you provide) on each element of the array, resulting in single output value.
|
<R> R |
reduce(JsArray.Reduce2<? extends R,T> reducer,
R initialValue)
The reduce() method executes a reducer function (that you provide) on each element of the array, resulting in single output value.
|
<R> R |
reduce(JsArray.Reduce3<? extends R,T> reducer)
The reduce() method executes a reducer function (that you provide) on each element of the array, resulting in single output value.
|
<R> R |
reduce(JsArray.Reduce3<? extends R,T> reducer,
R initialValue)
The reduce() method executes a reducer function (that you provide) on each element of the array, resulting in single output value.
|
<R> R |
reduceRight(JsArray.Reduce<? extends R,T> reducer)
The reduceRight() method applies a function against an accumulator and each value of the array (from right-to-left) to reduce it to a single value.
|
<R> R |
reduceRight(JsArray.Reduce<? extends R,T> reducer,
R initialValue)
The reduceRight() method applies a function against an accumulator and each value of the array (from right-to-left) to reduce it to a single value.
|
<R> R |
reduceRight(JsArray.Reduce2<? extends R,T> reducer)
The reduceRight() method applies a function against an accumulator and each value of the array (from right-to-left) to reduce it to a single value.
|
<R> R |
reduceRight(JsArray.Reduce2<? extends R,T> reducer,
R initialValue)
The reduceRight() method applies a function against an accumulator and each value of the array (from right-to-left) to reduce it to a single value.
|
<R> R |
reduceRight(JsArray.Reduce3<? extends R,T> reducer)
The reduceRight() method applies a function against an accumulator and each value of the array (from right-to-left) to reduce it to a single value.
|
<R> R |
reduceRight(JsArray.Reduce3<? extends R,T> reducer,
R initialValue)
The reduceRight() method applies a function against an accumulator and each value of the array (from right-to-left) to reduce it to a single value.
|
JsArray<T> |
reverse()
The reverse() method reverses an array in place.
|
T |
shift()
The shift() method removes the first element from an array and returns that removed element.
|
JsArray<T> |
slice()
The slice() method returns a shallow copy of the array.
|
JsArray<T> |
slice(int begin)
The slice() method returns a shallow copy of a portion of an array into a new array object selected from start to end (end not included) where start and end represent the index of items in that array.
|
JsArray<T> |
slice(int begin,
int end)
The slice() method returns a shallow copy of a portion of an array into a new array object selected from start to end (end not included) where start and end represent the index of items in that array.
|
boolean |
some(JsArray.Predicate<T> predicate)
The some() method tests whether at least one element in the array passes the test implemented by the provided function.
|
boolean |
some(JsArray.Predicate2<T> predicate)
The some() method tests whether at least one element in the array passes the test implemented by the provided function.
|
boolean |
some(JsArray.Predicate3<T> predicate)
The some() method tests whether at least one element in the array passes the test implemented by the provided function.
|
JsArray<T> |
sort()
The sort() method sorts the elements of an array in place and returns the sorted array.
|
JsArray<T> |
sort(JsArray.Comparator<? super T> compareFunction)
The sort() method sorts the elements of an array in place and returns the sorted array.
|
JsArray<T> |
splice(int start)
The splice() method changes the contents of an array by removing or replacing existing elements and/or adding new elements in place.
|
JsArray<T> |
splice(int start,
int deleteCount,
T... items)
The splice() method changes the contents of an array by removing or replacing existing elements and/or adding new elements in place.
|
java.lang.String |
toString_()
The toString() method returns a string representing the specified array and its elements.
|
int |
unshift(T... elements)
The unshift() method adds one or more elements to the beginning of an array and returns the new length of the array.
|
JsIteratorIterable<T> |
values()
The values() method returns a new Array Iterator object that contains the values for each index in the array.
|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waititeratorpublic int length
@SafeVarargs
public JsArray(@Nonnull
T... items)
@JsOverlay @Nonnull public static <T> JsArray<T> asJsArray(@Nonnull T[] array)
T - the type of the array elements.array - the native "java" array.@Nonnull public static <T,R> JsArray<R> from(@Nonnull jsinterop.base.JsArrayLike<T> arrayLike, @Nonnull JsArray.Converter<? super T,? extends R> mapFn)
@Nonnull public static <T,R> JsArray<R> from(@Nonnull jsinterop.base.JsArrayLike<T> arrayLike)
@Nonnull public static <T,R> JsArray<R> from(@Nonnull JsIterable<T> arrayLike, @Nonnull JsArray.Converter<? super T,? extends R> mapFn)
@Nonnull public static <T,R> JsArray<R> from(@Nonnull JsIterable<T> arrayLike)
@Nonnull public static <T,R> JsArray<R> from(@Nonnull T[] arrayLike, @Nonnull JsArray.Converter<? super T,? extends R> mapFn)
@Nonnull public static <T,R> JsArray<R> from(@Nonnull T[] arrayLike)
public static boolean isArray(@Nullable
java.lang.Object value)
@SafeVarargs @Nonnull public static <T> JsArray<T> of(@Nonnull T... var_args)
@JsOverlay public final T[] asArray(@Nonnull T[] reference)
reference - the "java" array that is the template type.@SafeVarargs @Nonnull public final JsArray<T> concat(@Nonnull T... items)
@Nonnull public JsArray<T> copyWithin(int target, int start, int end)
target - Zero-based index at which to copy the sequence to. If negative, target will be counted from the end. If target is at or greater than arr.length, nothing will be copied. If target is positioned after start, the copied sequence will be trimmed to fit arr.length.start - Zero-based index at which to start copying elements from. If negative, start will be counted from the end. If start is omitted, copyWithin will copy from index 0.end - Zero-based index at which to end copying elements from. copyWithin copies up to but not including end. If negative, end will be counted from the end.@Nonnull public JsArray<T> copyWithin(int target, int start)
target - Zero-based index at which to copy the sequence to. If negative, target will be counted from the end. If target is at or greater than arr.length, nothing will be copied. If target is positioned after start, the copied sequence will be trimmed to fit arr.length.start - Zero-based index at which to start copying elements from. If negative, start will be counted from the end. If start is omitted, copyWithin will copy from index 0.@Nonnull public JsIteratorIterable<JsArray<JsArray.Entry<T>>> entries()
public boolean every(@Nonnull
JsArray.Predicate<T> predicate)
predicate - A function to test each element.public boolean every(@Nonnull
JsArray.Predicate2<T> predicate)
predicate - A function to test each element.public boolean every(@Nonnull
JsArray.Predicate3<T> predicate)
predicate - A function to test each element.@Nonnull public JsArray<T> fill(@Nullable T value, int begin, int end)
value - the value to fill the array with.begin - the start index.end - the end index.@Nonnull public JsArray<T> fill(@Nullable T value, int begin)
value - the value to fill the array with.begin - the start index.@Nonnull public JsArray<T> fill(@Nullable T value)
value - the value to fill the array with.@Nonnull public JsArray<T> filter(@Nonnull JsArray.Predicate<T> predicate)
predicate - the function used to test each element.@Nonnull public JsArray<T> filter(@Nonnull JsArray.Predicate2<T> predicate)
predicate - the function used to test each element.@Nonnull public JsArray<T> filter(@Nonnull JsArray.Predicate3<T> predicate)
predicate - the function used to test each element.@Nullable public T find(@Nonnull JsArray.Predicate<T> predicate)
predicate - the function used to test each element.@Nullable public T find(@Nonnull JsArray.Predicate2<T> predicate)
predicate - the function used to test each element.@Nullable public T find(@Nonnull JsArray.Predicate3<T> predicate)
predicate - the function used to test each element.public int findIndex(@Nonnull
JsArray.Predicate<T> predicate)
predicate - the function used to test each element.public int findIndex(@Nonnull
JsArray.Predicate2<T> predicate)
predicate - the function used to test each element.public int findIndex(@Nonnull
JsArray.Predicate3<T> predicate)
predicate - the function used to test each element.@Nonnull public <S> JsArray<S> flat()
@Nonnull public <S> JsArray<S> flat(double depth)
depth - the depth level specifying how deep a nested array structure should be flattened.@Nonnull public <S> JsArray<S> flatMap(@Nonnull JsArray.FlatMap<S,T> callback)
callback - the function that produces an element of the new Array.@Nonnull public <S> JsArray<S> flatMap(@Nonnull JsArray.FlatMap2<S,T> callback)
callback - the function that produces an element of the new Array.@Nonnull public <S> JsArray<S> flatMap(@Nonnull JsArray.FlatMap3<S,T> callback)
callback - the function that produces an element of the new Array.public void forEach(@Nonnull
JsArray.ForEachCallback<T> callback)
callback - the function to execute for each element in the Array.public void forEach(@Nonnull
JsArray.ForEachCallback2<T> callback)
callback - the function to execute for each element in the Array.public void forEach(@Nonnull
JsArray.ForEachCallback3<T> callback)
callback - the function to execute for each element in the Array.public boolean includes(@Nullable
T searchElement,
int fromIndex)
searchElement - the value to search for.fromIndex - the position in this array at which to begin searching for searchElement.public boolean includes(@Nullable
T searchElement)
searchElement - the value to search for.public int indexOf(@Nonnull
T searchElement,
int fromIndex)
searchElement - the value to search for.fromIndex - the position in this array at which to begin searching for searchElement.public int indexOf(@Nonnull
T searchElement)
searchElement - the value to search for.@Nonnull
public java.lang.String join(@Nonnull
java.lang.String separator)
separator - specifies a string to separate each pair of adjacent elements of the array. If separator is an empty string, all elements are joined without any characters in between them.@Nonnull public java.lang.String join()
@Nonnull public JsIteratorIterable<java.lang.Double> keys()
public int lastIndexOf(@Nullable
T searchElement,
int fromIndex)
searchElement - the value to search for.fromIndex - the index at which to start searching backwards.public int lastIndexOf(@Nullable
T searchElement)
searchElement - the value to search for.@Nonnull public <R> JsArray<R> map(@Nonnull JsArray.Map<? extends R,T> callback)
callback - the callback that is called for every element of this array. Each time callback executes, the returned value is added to the new array.@Nonnull public <R> JsArray<R> map(@Nonnull JsArray.Map2<? extends R,T> callback)
callback - the callback that is called for every element of this array. Each time callback executes, the returned value is added to the new array.@Nonnull public <R> JsArray<R> map(@Nonnull JsArray.Map3<? extends R,T> callback)
callback - the callback that is called for every element of this array. Each time callback executes, the returned value is added to the new array.public T pop()
@SafeVarargs
public final int push(@Nonnull
T... elements)
elements - the elements to add to the end of the array.public <R> R reduce(@Nonnull
JsArray.Reduce<? extends R,T> reducer,
R initialValue)
reducer - a function to execute on each element in the array.public <R> R reduce(@Nonnull
JsArray.Reduce2<? extends R,T> reducer,
R initialValue)
reducer - a function to execute on each element in the array.public <R> R reduce(@Nonnull
JsArray.Reduce3<? extends R,T> reducer,
R initialValue)
reducer - a function to execute on each element in the array.public <R> R reduce(@Nonnull
JsArray.Reduce<? extends R,T> reducer)
reducer - a function to execute on each element in the array except for the first.public <R> R reduce(@Nonnull
JsArray.Reduce2<? extends R,T> reducer)
reducer - a function to execute on each element in the array except for the first.public <R> R reduce(@Nonnull
JsArray.Reduce3<? extends R,T> reducer)
reducer - a function to execute on each element in the array except for the first.public <R> R reduceRight(@Nonnull
JsArray.Reduce<? extends R,T> reducer,
R initialValue)
reducer - a function to execute on each element in the array.public <R> R reduceRight(@Nonnull
JsArray.Reduce2<? extends R,T> reducer,
R initialValue)
reducer - a function to execute on each element in the array.public <R> R reduceRight(@Nonnull
JsArray.Reduce3<? extends R,T> reducer,
R initialValue)
reducer - a function to execute on each element in the array.public <R> R reduceRight(@Nonnull
JsArray.Reduce<? extends R,T> reducer)
reducer - a function to execute on each element in the array except for the last.public <R> R reduceRight(@Nonnull
JsArray.Reduce2<? extends R,T> reducer)
reducer - a function to execute on each element in the array except for the last.public <R> R reduceRight(@Nonnull
JsArray.Reduce3<? extends R,T> reducer)
reducer - a function to execute on each element in the array except for the last.@Nonnull public JsArray<T> reverse()
public T shift()
@Nonnull public JsArray<T> slice(int begin, int end)
begin - the zero-based index at which to start extraction. A negative index can be used, indicating an offset from the end of the sequence. slice(-2) extracts the last two elements in the sequence.end - the zero-based index before which to end extraction. slice extracts up to but not including end. For example, slice(1,4) extracts the second element through the fourth element (elements indexed 1, 2, and 3). A negative index can be used, indicating an offset from the end of the sequence. slice(2,-1) extracts the third element through the second-to-last element in the sequence.@Nonnull public JsArray<T> slice(int begin)
begin - the zero-based index at which to start extraction. A negative index can be used, indicating an offset from the end of the sequence. slice(-2) extracts the last two elements in the sequence.@Nonnull public JsArray<T> slice()
public boolean some(@Nonnull
JsArray.Predicate<T> predicate)
predicate - a predicate to test each element.public boolean some(@Nonnull
JsArray.Predicate2<T> predicate)
predicate - a predicate to test each element.public boolean some(@Nonnull
JsArray.Predicate3<T> predicate)
predicate - a predicate to test each element.@Nonnull public JsArray<T> sort(@Nonnull JsArray.Comparator<? super T> compareFunction)
compareFunction - the function that defines the sort order.@Nonnull public JsArray<T> sort()
@SafeVarargs @Nonnull public final JsArray<T> splice(int start, int deleteCount, @Nonnull T... items)
start - The index at which to start changing the array. If greater than the length of the array, start will be set to the length of the array. In this case, no element will be deleted but the method will behave as an adding function, adding as many element as item[n*] provided. If negative, it will begin that many elements from the end of the array.deleteCount - An integer indicating the number of elements in the array to remove from start. If deleteCount is omitted, or if its value is equal to or larger than array.length - start (that is, if it is equal to or greater than the number of elements left in the array, starting at start), then all the elements from start to the end of the array will be deleted. If deleteCount is 0 or negative, no elements are removed. In this case, you should specify at least one new elementitems - the elements to add to the array, beginning from start. If you do not specify any elements, splice() will only remove elements from the array.@Nonnull public JsArray<T> splice(int start)
start - The index at which to start changing the array. If greater than the length of the array, start will be set to the length of the array. In this case, no element will be deleted but the method will behave as an adding function, adding as many element as item[n*] provided. If negative, it will begin that many elements from the end of the array.@JsMethod(name="toString") @Nonnull public java.lang.String toString_()
@SafeVarargs
public final int unshift(@Nonnull
T... elements)
elements - the elements to add to the front of the array.@Nonnull public JsIteratorIterable<T> values()