interface CollectionIteration<TOut, TIn> {
    length: number;
    [iterator](): Iterator<TOut, any, any>;
    each(each: ((ele: TIn, i: number, eles: this) => boolean | void), thisArg?: any): this;
    empty(): boolean;
    eq(index: number): TOut;
    first(): TOut;
    forEach(each: ((ele: TIn, i: number, eles: this) => boolean | void), thisArg?: any): this;
    last(): TOut;
    nonempty(): boolean;
    size(): number;
    slice(start?: number, end?: number): this;
    toArray(): TOut[];
    [index: number]: TOut;
}

Type Parameters

  • TOut
  • TIn

Hierarchy (view full)

Indexable

  • [index: number]: TOut

    Get an element at a particular index in the collection.

Properties

length: number

Get the number of elements in the collection.

Methods

  • Iterate over the elements in the collection using an implementation like the native array function namesake.

    This function behaves like Array.prototype.forEach() with minor changes for convenience: You can exit the iteration early by returning false in the iterating function. The Array.prototype.forEach() implementation does not support this, but it is included anyway on account of its utility.

    Parameters

    • each: ((ele: TIn, i: number, eles: this) => boolean | void)

      The function executed each iteration. ele - The current element. i - The index of the current element. eles - The collection of elements being iterated.

        • (ele, i, eles): boolean | void
        • Parameters

          • ele: TIn
          • i: number
          • eles: this

          Returns boolean | void

    • OptionalthisArg: any

      [optional] The value for this within the iterating function.

    Returns this

  • Get a subset of the elements in the collection based on specified indices.

    Parameters

    • Optionalstart: number

      [optional] An integer that specifies where to start the selection. The first element has an index of 0. Use negative numbers to select from the end of an array.

    • Optionalend: number

      [optional] An integer that specifies where to end the selection. If omitted, all elements from the start position and to the end of the array will be selected. Use negative numbers to select from the end of an array.

    Returns this