Options
All
  • Public
  • Public/Protected
  • All
Menu

Class LazyIterable<T>

Represents an iterable object that can be chained and is only evaluated once it is iterated.

Type parameters

  • T

Hierarchy

  • LazyIterable

Implements

  • Iterable<T>

Index

Constructors

constructor

  • Creates a LazyIterable from an iterable object.

    Parameters

    • source: Iterable<T>

      An iterable object from which to create a LazyIterable.

    Returns LazyIterable

  • Creates a LazyIterable from a function.

    Parameters

    • source: function

      An iterable object from which to create a LazyIterable.

        • (): Iterator<T>
        • Returns Iterator<T>

    Returns LazyIterable

Properties

Private _generator

_generator: function

Type declaration

    • (): Iterator<T>
    • Returns Iterator<T>

Accessors

length

  • get length(): number
  • Returns the number of items iterated by this instance. Accessing this property causes this instance to be iterated.

    Returns number

Methods

__@iterator

  • __@iterator(): Iterator<T>
  • Returns an iterator for this instance.

    Returns Iterator<T>

concat

  • Returns a new LazyIterable with the specified iterable objects concatenated to it.

    Parameters

    • Rest ...values: Iterable<T>[]

      An array of iterable object to be concatenated to this instance.

    Returns LazyIterable<T>

  • Returns a new LazyIterable with the specified items or items of the specified iterable objects concatenated to this instance.

    Parameters

    • Rest ...values: (T | Iterable<T>)[]

      An array of items or iterable objects whose items are to be to concatenated to this instance.

    Returns LazyIterable<T>

entries

  • Returns a new LazyIterable that iterates the index/value pairs of the items of this instance.

    Returns LazyIterable<[number, T]>

every

  • every(callback: function, thisArg?: any): boolean
  • Determines whether every item in this instance fulfills a predicate. Calling this method causes this instance to be iterated.

    Parameters

    • callback: function

      A predicate function to test each item against.

        • (value: T, index?: undefined | number, source?: LazyIterable<T>): void
        • Parameters

          • value: T
          • Optional index: undefined | number
          • Optional source: LazyIterable<T>

          Returns void

    • Default value thisArg: any = this

      The value to use as this when executing callback.

    Returns boolean

filter

  • filter(callback: function, thisArg?: any): LazyIterable<T>
  • Returns a new LazyIterable that will iterate only the items that fulfill the specified predicate.

    Parameters

    • callback: function

      A predicate function to test each item against.

        • (value: T, index?: undefined | number, source?: LazyIterable<T>): void
        • Parameters

          • value: T
          • Optional index: undefined | number
          • Optional source: LazyIterable<T>

          Returns void

    • Default value thisArg: any = this

      The value to use as this when executing callback.

    Returns LazyIterable<T>

find

  • find(callback: function, thisArg?: any): T | undefined
  • Returns the first item that fulfills the specified predicate. Calling this method causes this instance to be iterated.

    Parameters

    • callback: function

      A predicate function to test each item against.

        • (value: T, index?: undefined | number, source?: LazyIterable<T>): void
        • Parameters

          • value: T
          • Optional index: undefined | number
          • Optional source: LazyIterable<T>

          Returns void

    • Default value thisArg: any = this

      The value to use as this when executing callback.

    Returns T | undefined

findIndex

  • findIndex(callback: function, thisArg?: any): number
  • Returns the index of the first item that fulfills the specified predicate. Calling this method causes this instance to be iterated.

    Parameters

    • callback: function

      A predicate function to test each item against.

        • (value: T, index?: undefined | number, source?: LazyIterable<T>): void
        • Parameters

          • value: T
          • Optional index: undefined | number
          • Optional source: LazyIterable<T>

          Returns void

    • Default value thisArg: any = this

      The value to use as this when executing callback.

    Returns number

forEach

  • forEach(callback: function, thisArg?: any): void
  • Executes a function for each item in this instance. Calling this method causes this instance to be iterated.

    Parameters

    • callback: function

      The function to execute for each item.

        • (value: T, index?: undefined | number, source?: LazyIterable<T>): void
        • Parameters

          • value: T
          • Optional index: undefined | number
          • Optional source: LazyIterable<T>

          Returns void

    • Default value thisArg: any = this

      The value to use as this when executing callback.

    Returns void

includes

  • includes(searchValue: T, fromIndex?: number): boolean
  • Determines whether this instance includes a specified item. Calling this method causes this instance to be iterated.

    Parameters

    • searchValue: T

      The value to search for.

    • Default value fromIndex: number = 0

      The index from which to start searching.

    Returns boolean

indexOf

  • indexOf(searchValue: T, fromIndex?: number): number
  • Returns the first index of the specified item in this instance. Calling this method causes this instance to be iterated.

    Parameters

    • searchValue: T

      The value to search for.

    • Default value fromIndex: number = 0

      The index from which to start searching.

    Returns number

itemAt

  • itemAt(index: number): T | undefined
  • Returns the item at the specified index in this instance.

    Parameters

    • index: number

      The index of the item.

    Returns T | undefined

join

  • join(separator?: string): string
  • Returns a string of all of the items in this instance. Calling this method causes this instance to be iterated.

    Parameters

    • Default value separator: string = ""

      A string used to separate the items in the resulting string.

    Returns string

keys

  • Returns a new LazyIterable that iterates the index of each item in this instance.

    Returns LazyIterable<number>

lastIndexOf

  • lastIndexOf(searchValue: T, fromIndex?: undefined | number): number
  • Returns the last index of the specified item in this instance by searching backward. Calling this method causes this instance to be iterated.

    Parameters

    • searchValue: T

      The value to search for.

    • Optional fromIndex: undefined | number

      The index from which to start searching backward.

    Returns number

map

  • map<U>(callback: function, thisArg?: any): LazyIterable<U>
  • Returns a new LazyIterable that iterates items of this instance transformed by a function. Calling this method causes this instance to be iterated.

    Type parameters

    • U

    Parameters

    • callback: function

      The function that transforms each item.

        • (value: T, index?: undefined | number, source?: LazyIterable<T>): U
        • Parameters

          • value: T
          • Optional index: undefined | number
          • Optional source: LazyIterable<T>

          Returns U

    • Default value thisArg: any = this

      The value to use as this when executing callback.

    Returns LazyIterable<U>

reduce

  • reduce(callback: function): T
  • reduce<U>(callback: function): U
  • reduce<U>(callback: function, initialValue: U): U
  • Returns the result of a reducing function called for each item in this instance. Calling this method causes this instance to be iterated.

    Parameters

    • callback: function

      The reducing function to to call on each item.

        • (previousValue: T, currentValue: T, currentIndex?: undefined | number, source?: LazyIterable<T>): T
        • Parameters

          • previousValue: T
          • currentValue: T
          • Optional currentIndex: undefined | number
          • Optional source: LazyIterable<T>

          Returns T

    Returns T

  • Returns the result of a reducing function called for each item in this instance. Calling this method causes this instance to be iterated.

    Type parameters

    • U

    Parameters

    • callback: function

      The reducing function to to call on each item.

        • (previousValue: T | U, currentValue: T, currentIndex?: undefined | number, source?: LazyIterable<T>): U
        • Parameters

          • previousValue: T | U
          • currentValue: T
          • Optional currentIndex: undefined | number
          • Optional source: LazyIterable<T>

          Returns U

    Returns U

  • Returns the result of a reducing function called for each item in this instance. Calling this method causes this instance to be iterated.

    Type parameters

    • U

    Parameters

    • callback: function

      The reducing function to to call on each item.

        • (previousValue: U, currentValue: T, currentIndex?: undefined | number, source?: LazyIterable<T>): U
        • Parameters

          • previousValue: U
          • currentValue: T
          • Optional currentIndex: undefined | number
          • Optional source: LazyIterable<T>

          Returns U

    • initialValue: U

      The initial value used in the reducing function.

    Returns U

reduceRight

  • reduceRight(callback: function): T
  • reduceRight<U>(callback: function): U
  • reduceRight<U>(callback: function, initialValue: U): U
  • Returns the result of a reducing function called for each item in this instance in reverse order. Calling this method causes this instance to be iterated.

    Parameters

    • callback: function

      The reducing function to to call on each item.

        • (previousValue: T, currentValue: T, currentIndex?: undefined | number, source?: LazyIterable<T>): T
        • Parameters

          • previousValue: T
          • currentValue: T
          • Optional currentIndex: undefined | number
          • Optional source: LazyIterable<T>

          Returns T

    Returns T

  • Returns the result of a reducing function called for each item in this instance in reverse order. Calling this method causes this instance to be iterated.

    Type parameters

    • U

    Parameters

    • callback: function

      The reducing function to to call on each item.

        • (previousValue: T | U, currentValue: T, currentIndex?: undefined | number, source?: LazyIterable<T>): U
        • Parameters

          • previousValue: T | U
          • currentValue: T
          • Optional currentIndex: undefined | number
          • Optional source: LazyIterable<T>

          Returns U

    Returns U

  • Returns the result of a reducing function called for each item in this instance in reverse order. Calling this method causes this instance to be iterated.

    Type parameters

    • U

    Parameters

    • callback: function

      The reducing function to to call on each item.

        • (previousValue: U, currentValue: T, currentIndex?: undefined | number, source?: LazyIterable<T>): U
        • Parameters

          • previousValue: U
          • currentValue: T
          • Optional currentIndex: undefined | number
          • Optional source: LazyIterable<T>

          Returns U

    • initialValue: U

      The initial value used in the reducing function.

    Returns U

reverse

  • Returns new LazyIterable that iterates the items in this instance in reverse order.

    Returns LazyIterable<T>

slice

  • slice(begin?: number, end?: undefined | number): LazyIterable<T>
  • Returns a new LazyIterable that iterates a portions of the items in this instance.

    Parameters

    • Default value begin: number = 0

      The index of the first item to include.

    • Optional end: undefined | number

      The index of the first item to exclude.

    Returns LazyIterable<T>

some

  • some(callback: function, thisArg?: any): boolean
  • Determines whether any item in this instance fulfills a predicate. Calling this method causes this instance to be iterated.

    Parameters

    • callback: function

      A predicate function to test each item against.

        • (element: T, index?: undefined | number, source?: LazyIterable<T>): boolean
        • Parameters

          • element: T
          • Optional index: undefined | number
          • Optional source: LazyIterable<T>

          Returns boolean

    • Default value thisArg: any = this

      The value to use as this when executing callback.

    Returns boolean

sort

  • sort(compareFunction?: undefined | function): LazyIterable<T>
  • Returns a new LazyIterable that iterates the items in this instances in sorted order.

    Parameters

    • Optional compareFunction: undefined | function

      A function that determines the order of the items.

    Returns LazyIterable<T>

toArray

  • toArray(): T[]
  • Returns an array of the items in this instance. Calling this method causes this instance to be iterated.

    Returns T[]

values

  • Returns new LazyIterable that iterates the items in this instance.

    Returns LazyIterable<T>

Static from

  • Creates a LazyIterable from an iterable object.

    Type parameters

    • T

    Parameters

    • source: Iterable<T>

      An iterable object from which to create a LazyIterable.

    Returns LazyIterable<T>

Generated using TypeDoc