enumerate<T> function

Stream<IndexedValue<T>> enumerate<T>(
  1. Stream<T> stream
)

Returns a Stream of IndexedValues where the nth value holds the nth element of stream and its index.

Implementation

Stream<IndexedValue<T>> enumerate<T>(Stream<T> stream) {
  var index = 0;
  return stream.map((value) => IndexedValue<T>(index++, value));
}