All Downloads are FREE. Search and download functionalities are using the official Maven repository.

elemental2.core.ReadonlyArray 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 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, namespace = JsPackage.GLOBAL)
public interface ReadonlyArray extends JsIterable, JsArrayLike {
  @JsType(isNative = true, name = "?", namespace = JsPackage.GLOBAL)
  public interface EntriesJsIteratorIterableTypeParameterArrayUnionType {
    @JsOverlay
    static ReadonlyArray.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);
  }

  @JsFunction
  public interface FilterCallbackFn {
    Object onInvoke(T p0, int p1);
  }

  @JsFunction
  public interface FindIndexPredicateFn {
    Object onInvoke(T p0, double p1, JsArray p2);

    @JsOverlay
    default Object onInvoke(T p0, double p1, T[] p2) {
      return onInvoke(p0, p1, Js.>uncheckedCast(p2));
    }
  }

  @JsFunction
  public interface FindLastIndexPredicateFn {
    boolean onInvoke(T p0, double p1, JsArray p2);

    @JsOverlay
    default boolean onInvoke(T p0, double p1, T[] p2) {
      return onInvoke(p0, p1, Js.>uncheckedCast(p2));
    }
  }

  @JsFunction
  public interface FindLastPredicateFn {
    boolean onInvoke(T p0, double p1, JsArray p2);

    @JsOverlay
    default boolean onInvoke(T p0, double p1, T[] p2) {
      return onInvoke(p0, p1, Js.>uncheckedCast(p2));
    }
  }

  @JsFunction
  public interface FindPredicateFn {
    Object onInvoke(T p0, double p1, JsArray p2);

    @JsOverlay
    default Object onInvoke(T p0, double p1, T[] p2) {
      return onInvoke(p0, p1, Js.>uncheckedCast(p2));
    }
  }

  @JsFunction
  public interface FlatMapCallbackFn {
    ReadonlyArray onInvoke(T p0, double p1, JsArrayLike p2);

    @JsOverlay
    default ReadonlyArray onInvoke(T p0, double p1, T[] p2) {
      return onInvoke(p0, p1, Js.>uncheckedCast(p2));
    }
  }

  @JsFunction
  public interface ForEachCallbackFn {
    Object onInvoke(T p0, int p1);
  }

  @JsFunction
  public interface MapCallbackFn {
    R onInvoke(T p0, int p1);
  }

  @JsFunction
  public interface ReduceCallbackFn {
    R onInvoke(Object p0, T p1, int p2);
  }

  @JsFunction
  public interface ReduceRightCallbackFn {
    R onInvoke(Object p0, T p1, int p2);
  }

  @JsFunction
  public interface SomeCallbackFn {
    Object onInvoke(T p0, int p1);
  }

  T at(int index);

  JsArray concat(T... items);

  JsIteratorIterable>>
      entries();

   boolean every(ReadonlyArray.EveryCallbackFn callback, S thisobj);

  boolean every(ReadonlyArray.EveryCallbackFn callback);

   JsArray filter(ReadonlyArray.FilterCallbackFn callback, S thisobj);

  JsArray filter(ReadonlyArray.FilterCallbackFn callback);

   T find(ReadonlyArray.FindPredicateFn predicateFn, S this_);

  T find(ReadonlyArray.FindPredicateFn predicateFn);

   int findIndex(ReadonlyArray.FindIndexPredicateFn predicateFn, S this_);

  int findIndex(ReadonlyArray.FindIndexPredicateFn predicateFn);

   T findLast(ReadonlyArray.FindLastPredicateFn predicateFn, S this_);

  T findLast(ReadonlyArray.FindLastPredicateFn predicateFn);

   int findLastIndex(ReadonlyArray.FindLastIndexPredicateFn predicateFn, S this_);

  int findLastIndex(ReadonlyArray.FindLastIndexPredicateFn predicateFn);

   JsArray flat();

   JsArray flat(int depth);

   JsArray flatMap(ReadonlyArray.FlatMapCallbackFn callback, THIS thisArg);

   JsArray flatMap(ReadonlyArray.FlatMapCallbackFn callback);

   void forEach(ReadonlyArray.ForEachCallbackFn callback, S thisobj);

  void forEach(ReadonlyArray.ForEachCallbackFn callback);

  boolean includes(T searchElement, int fromIndex);

  boolean includes(T searchElement);

  int indexOf(T obj, int fromIndex);

  int indexOf(T obj);

  String join();

  String join(Object separator);

  JsIteratorIterable keys();

  int lastIndexOf(T obj, int fromIndex);

  int lastIndexOf(T obj);

   JsArray map(ReadonlyArray.MapCallbackFn callback, S thisobj);

   JsArray map(ReadonlyArray.MapCallbackFn callback);

   R reduce(
      ReadonlyArray.ReduceCallbackFn callback, Object initialValue);

   R reduce(ReadonlyArray.ReduceCallbackFn callback);

   R reduceRight(
      ReadonlyArray.ReduceRightCallbackFn callback, Object initialValue);

   R reduceRight(ReadonlyArray.ReduceRightCallbackFn callback);

  JsArray slice();

  JsArray slice(int begin, int end);

  JsArray slice(int begin);

   boolean some(ReadonlyArray.SomeCallbackFn callback, S thisobj);

  boolean some(ReadonlyArray.SomeCallbackFn callback);

  @JsMethod(name = "toString")
  String toString_();

  JsIteratorIterable values();
}