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 2a7c28d commit c68f349Copy full SHA for c68f349
index.ts
@@ -86,3 +86,13 @@ export async function asyncToSetOnce<T>(iterator: AsyncIteratorLike<T>): Promise
86
}
87
return set;
88
89
+
90
+export async function asyncFirstOnce<T>(iterator: AsyncIteratorLike<T>): Promise<T | null> {
91
+ const it = asyncIterator(iterator);
92
+ const element = await it.next();
93
+ if (element.done === true) {
94
+ return null;
95
+ } else {
96
+ return element.value;
97
+ }
98
+}
0 commit comments