Press n or j to go to the next uncovered block, b, p or k for the previous block.
| 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 | 101x 10x 91x 5x 5x 5x 10x 2x 8x 8x 5x | /**
* Indicates whether the given iterable iterator has any items.
* @param iterable A iterable iterator.
* @returns `true` if the iterator has any items, `false` otherwise.
*/
export function any<T>(iterable: IterableIterator<T>): boolean {
for (const _ of iterable) {
return true;
}
return false;
}
/**
* Takes items from the beginning of an iterable iterator.
* @param iterable A iterable iterator.
* @param count The number of items to consume from the iterator.
* @returns An array that contains up to `count` items from the iterator.
*/
export function take<T>(iterable: IterableIterator<T>, count: number): T[] {
const result: T[] = [];
let i = 0;
for (const item of iterable) {
if (i >= count) {
break;
}
result.push(item);
i++;
}
return result;
} |