We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent 53351e8 commit d370690Copy full SHA for d370690
packages/common/src/util/itertools.ts
@@ -66,6 +66,13 @@ export function isEmptyIterable(iterable: Iterable<unknown>): boolean {
66
return true;
67
}
68
69
+/**
70
+ * Returns the first element of the given iterable, or `undefined` if the
71
+ * iterable is empty
72
+ * @param iterable The iterable to get the first element of
73
+ * @returns The first element of the iterable, or `undefined` if the iterable
74
+ * is empty
75
+ */
76
export function next<T>(generator: Iterable<T>): T | undefined {
77
for (const value of generator) {
78
return value;
0 commit comments