Options
All
  • Public
  • Public/Protected
  • All
Menu

Class IteratorWithOperators<T>

Type parameters

  • T

Hierarchy

  • IteratorWithOperators

Implements

  • IterableIterator<T>

Index

Constructors

constructor

Properties

Private source

source: Iterator<T>

Iterator to wrap

Methods

__@iterator

  • __@iterator(): this
  • The presence of this method makes the Iterator itself Iterable. This makes it possible to pass it to for of and Iterable-accepting functions like Array.from()

    Returns this

concat

  • Returns a new Iterator concatenating the Iterator with an additional Iterator or Iterable

    Type parameters

    • C

    Parameters

    • collection: Iterable<C> | Iterator<C>

    Returns IteratorWithOperators<T | C>

drop

  • Returns a new Iterator that emits slice of the source with n elements dropped from the beginning

    Parameters

    • n: number

      The number of elements to drop.

    Returns IteratorWithOperators<T>

every

  • every(predicate: function): boolean
  • Iterates and checks if predicate returns truthy for all elements emitted by the Iterator

    Parameters

    • predicate: function
        • (value: T): boolean
        • Parameters

          • value: T

          Returns boolean

    Returns boolean

filter

  • Returns a new Iterator of all elements predicate returns truthy for

    Parameters

    • predicate: function
        • (element: T): boolean
        • Parameters

          • element: T

          Returns boolean

    Returns IteratorWithOperators<T>

  • Type parameters

    • R: T

    Parameters

    • predicate: function
        • (element: T): boolean
        • Parameters

          • element: T

          Returns boolean

    Returns IteratorWithOperators<R>

flatten

forEach

  • forEach(iteratee: function): void
  • Iterates and invokes iteratee for every element emitted by the Iterator

    Parameters

    • iteratee: function
        • (value: T): any
        • Parameters

          • value: T

          Returns any

    Returns void

includes

  • includes(value: T): boolean
  • Iterates and checks if value is emitted by the Iterator

    Parameters

    • value: T

      The value to search

    Returns boolean

join

  • join(separator?: string): string
  • Iterates and joins all elements emitted by the Iterator together as a string separated by an optional separator

    Parameters

    • Default value separator: string = ","

    Returns string

map

  • Returns a new Iterator by running each element thru iteratee

    Type parameters

    • R

    Parameters

    • iteratee: function
        • (value: T): R
        • Parameters

          • value: T

          Returns R

    Returns IteratorWithOperators<R>

next

  • next(): IteratorResult<T>
  • Returns a { value, done } object that adheres to the Iterator protocol

    Returns IteratorResult<T>

reduce

  • reduce(iteratee: function): T
  • reduce<A>(iteratee: function, initialValue: A): A
  • Reduces the Iterator to a value which is the accumulated result of running each emitted element thru iteratee, where each successive invocation is supplied the return value of the previous. The first element of collection is used as the initial value.

    Parameters

    • iteratee: function
        • (acc: T, val: T): T
        • Parameters

          • acc: T
          • val: T

          Returns T

    Returns T

  • Reduces the Iterator to a value which is the accumulated result of running each emitted element thru iteratee, where each successive invocation is supplied the return value of the previous.

    Type parameters

    • A

    Parameters

    • iteratee: function
        • (acc: A, val: T): A
        • Parameters

          • acc: A
          • val: T

          Returns A

    • initialValue: A

      The initial value for acc

    Returns A

slice

  • Returns a new Iterator that emits a slice of the source

    Parameters

    • start: number

      Zero-based positive start index, inclusive

    • Default value end: number = Infinity

      Zero-based positive end index, exclusive, defaults to end of iterator

    Returns IteratorWithOperators<T>

some

  • some(predicate: function): boolean
  • Iterates and checks if predicate returns truthy for any element emitted by the Iterator

    Parameters

    • predicate: function
        • (value: T): boolean
        • Parameters

          • value: T

          Returns boolean

    Returns boolean

take

  • Returns a new Iterator that emits slice of the source with n elements taken from the beginning

    Parameters

    • limit: number

      The number of elements to take.

    Returns IteratorWithOperators<T>

toArray

  • toArray(): T[]
  • Iterates and returns all items emitted by the Iterator as an array. Equivalent to passing the Iterator to Array.from()

    Returns T[]

toMap

  • toMap<K, V>(): Map<K, V>
  • Iterates and returns all [key, value] paris emitted by the Iterator as an ES6 Map. Equivalent to passing the Iterator to new Map()

    Type parameters

    • K

    • V

    Returns Map<K, V>

toSet

  • toSet(): Set<T>
  • Iterates and returns all items emitted by the Iterator as an ES6 Set. Equivalent to passing the Iterator to new Set()

    Returns Set<T>

Generated using TypeDoc