Returns the size of an Iterable. In order to reuse the Iterable that was passed, make sure to convert it to a MultipleIterable first.
import { Iterable } from 'ts-arrays'
function* generator() {
let counter = 0;
while (counter < 3) {
yield counter++;
}
}
const iterator = generator()
const sizeOfIterable: number = Iterables.size(multipleIterable)
// => 3
Iterating over an iterator is said to consume the iterator, because it is generally only possible to do once. This method returns an Iterable that can be iterated multiple times (e.g. in multiple for...of loops)
import { Iterable } from 'ts-arrays'
function* generator() {
let counter = 0;
while (counter < 3) {
yield counter++;
}
}
const iterator = generator()
const multipleIterable = Iterables.toMultipleIterable(iterator)
An iterable
Generated using TypeDoc
Utility methods for Iterables.