Skip to content

Commit 89302cb

Browse files
authored
Update dom.asynciterable.generated.d.ts
1 parent 81c9518 commit 89302cb

1 file changed

Lines changed: 66 additions & 11 deletions

File tree

src/lib/dom.asynciterable.generated.d.ts

Lines changed: 66 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -2,22 +2,77 @@
22
/// Window Async Iterable APIs
33
/////////////////////////////
44

5-
interface FileSystemDirectoryHandleAsyncIterator<T> extends AsyncIteratorObject<T, BuiltinIteratorReturn, unknown> {
6-
[Symbol.asyncIterator](): FileSystemDirectoryHandleAsyncIterator<T>;
7-
}
5+
/**
6+
* Generic async iterable iterator type that conforms to both
7+
* AsyncIterator and AsyncIterable protocols.
8+
*/
9+
type AsyncIterableIterator<T> = AsyncIterator<T, void, unknown> & {
10+
[Symbol.asyncIterator](): AsyncIterableIterator<T>;
11+
};
12+
13+
// ==========================
14+
// File System Access API
15+
// ==========================
816

17+
/**
18+
* Represents a handle to a file or directory.
19+
* Extend this interface based on actual implementation or spec.
20+
*/
21+
interface FileSystemHandle {} // Placeholder for real handle definition
22+
23+
/**
24+
* Represents a directory handle capable of returning async iterators
25+
* for entries (key-value pairs), keys (file/directory names), and values (handles).
26+
*/
927
interface FileSystemDirectoryHandle {
10-
[Symbol.asyncIterator](): FileSystemDirectoryHandleAsyncIterator<[string, FileSystemHandle]>;
11-
entries(): FileSystemDirectoryHandleAsyncIterator<[string, FileSystemHandle]>;
12-
keys(): FileSystemDirectoryHandleAsyncIterator<string>;
13-
values(): FileSystemDirectoryHandleAsyncIterator<FileSystemHandle>;
28+
/**
29+
* Default async iterator over [name, handle] pairs.
30+
*/
31+
[Symbol.asyncIterator](): AsyncIterableIterator<[string, FileSystemHandle]>;
32+
33+
/**
34+
* Returns an async iterator over [name, handle] pairs.
35+
*/
36+
entries(): AsyncIterableIterator<[string, FileSystemHandle]>;
37+
38+
/**
39+
* Returns an async iterator over file/directory names (keys).
40+
*/
41+
keys(): AsyncIterableIterator<string>;
42+
43+
/**
44+
* Returns an async iterator over file/directory handles (values).
45+
*/
46+
values(): AsyncIterableIterator<FileSystemHandle>;
1447
}
1548

16-
interface ReadableStreamAsyncIterator<T> extends AsyncIteratorObject<T, BuiltinIteratorReturn, unknown> {
17-
[Symbol.asyncIterator](): ReadableStreamAsyncIterator<T>;
49+
// ==========================
50+
// ReadableStream API
51+
// ==========================
52+
53+
/**
54+
* Options for customizing the behavior of ReadableStream async iteration.
55+
*/
56+
interface ReadableStreamIteratorOptions {
57+
/**
58+
* If true, prevents canceling the stream when iteration ends early.
59+
*/
60+
preventCancel?: boolean;
1861
}
1962

63+
/**
64+
* Extends ReadableStream with async iteration support via Symbol.asyncIterator
65+
* and the `values()` method. This enables for-await-of streaming of chunks.
66+
*/
2067
interface ReadableStream<R = any> {
21-
[Symbol.asyncIterator](options?: ReadableStreamIteratorOptions): ReadableStreamAsyncIterator<R>;
22-
values(options?: ReadableStreamIteratorOptions): ReadableStreamAsyncIterator<R>;
68+
/**
69+
* Returns an async iterator over stream chunks.
70+
*/
71+
[Symbol.asyncIterator](options?: ReadableStreamIteratorOptions): AsyncIterableIterator<R>;
72+
73+
/**
74+
* Returns an async iterator over stream chunks.
75+
* Functionally identical to Symbol.asyncIterator().
76+
*/
77+
values(options?: ReadableStreamIteratorOptions): AsyncIterableIterator<R>;
2378
}

0 commit comments

Comments
 (0)