Options
All
  • Public
  • Public/Protected
  • All
Menu

Module IterTools

Index

Functions

all

  • all<_ContainerType>(container: Iterable<Promise<_ContainerType>>): Promise<Array<_ContainerType>>
  • Wait until all promises in a container resolve, returning an array of their results Beware: this function flattens the iterable!

    Type parameters

    • _ContainerType

    Parameters

    • container: Iterable<Promise<_ContainerType>>

      The container of promises to wait on

    Returns Promise<Array<_ContainerType>>

dfs_iter

  • dfs_iter<_ContainerType>(container: Iterable<_ContainerType>, getChildren: function): IterableIterator<_ContainerType>
  • Return an iterable that enumerates the nodes of a tree, depth-first

    Type parameters

    • _ContainerType

    Parameters

    • container: Iterable<_ContainerType>

      An iterable container of tree nodes

    • getChildren: function

      Lambda to retrieve the children of a given node. If the node has no children, this lambda should return either undefined or an empty array.

        • (i: _ContainerType): Iterable<_ContainerType> | undefined | EmptyArray<_ContainerType>
        • Parameters

          • i: _ContainerType

          Returns Iterable<_ContainerType> | undefined | EmptyArray<_ContainerType>

    Returns IterableIterator<_ContainerType>

filter

  • filter<_ContainerType>(container: Iterable<_ContainerType>, predicate: function): IterableIterator<_ContainerType>
  • Array.prototype.filter, but for iterables

    Type parameters

    • _ContainerType

    Parameters

    • container: Iterable<_ContainerType>

      An iterable container of values to filter

    • predicate: function

      A function that returns true if the given value should pass through the filter, false otherwise.

        • (i: _ContainerType): boolean
        • Parameters

          • i: _ContainerType

          Returns boolean

    Returns IterableIterator<_ContainerType>

isEmptyArray

  • isEmptyArray<_ContainerType>(test: unknown): test is EmptyArray<_ContainerType>
  • Type parameters

    • _ContainerType

    Parameters

    • test: unknown

    Returns test is EmptyArray<_ContainerType>

map

  • map<_ContainerType, _TransformedContainerType>(container: Iterable<_ContainerType>, fn: function): IterableIterator<_TransformedContainerType>
  • Array.prototype.map, but for iterables

    Type parameters

    • _ContainerType

    • _TransformedContainerType

    Parameters

    • container: Iterable<_ContainerType>

      An iterable container of values to map over

    • fn: function

      A function to apply to every value in the container

        • (i: _ContainerType): _TransformedContainerType
        • Parameters

          • i: _ContainerType

          Returns _TransformedContainerType

    Returns IterableIterator<_TransformedContainerType>

merge

  • merge<_ContainerType>(...iterators: Array<Iterable<_ContainerType>>): Iterable<_ContainerType>
  • Merge a heterogenous list of iteratables together into one iterable.

    Notes

    Each provided iterable will be appended in argument order.

    Type parameters

    • _ContainerType

    Parameters

    • Rest ...iterators: Array<Iterable<_ContainerType>>

    Returns Iterable<_ContainerType>

mergeUnique

  • mergeUnique<_ContainerType>(...iterators: Array<Iterable<_ContainerType>>): Iterable<_ContainerType>
  • Merge a list of iterables together, plucking any duplicates.

    NOTE: This function materializes the given iterables inside a Set, and thus is inappropriate for especially large iterables.

    Type parameters

    • _ContainerType

    Parameters

    • Rest ...iterators: Array<Iterable<_ContainerType>>

    Returns Iterable<_ContainerType>

Generated using TypeDoc