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 1aec907 commit bbe293bCopy full SHA for bbe293b
index.ts
@@ -34,6 +34,16 @@ export async function toArray<T>(iterable: AsyncIterableLike<T>): Promise<T[]> {
34
35
export const asyncToArray = toArray;
36
37
+export async function toSet<T>(iterable: AsyncIterableLike<T>): Promise<Set<T>> {
38
+ const set = new Set<T>();
39
+ for await (const element of await iterable) {
40
+ set.add(element);
41
+ }
42
+ return set;
43
+}
44
+
45
+export const asyncToSet = toSet;
46
47
export async function first<T>(iterable: AsyncIterableLike<T>): Promise<T | null> {
48
for await (const element of await iterable) {
49
return element;
0 commit comments