Skip to content
This repository has been archived by the owner on Feb 7, 2023. It is now read-only.

Updated types for 2021-12-21 #172

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 11 additions & 0 deletions index.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -788,6 +788,7 @@ declare class ReadableStream {
pipeThrough(transform: ReadableStreamTransform, options?: PipeToOptions): ReadableStream;
pipeTo(destination: WritableStream, options?: PipeToOptions): Promise<void>;
tee(): [ReadableStream, ReadableStream];
values(options?: ReadableStreamValuesOptions): ReadableStreamReadableStreamAsyncIterator;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is [Symbol.asyncIterator] implemented and just not showing up, or is that coming soon? cc @jasnell

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's landed. I think it might be going out this week.

}

declare class ReadableStreamBYOBReader {
Expand Down Expand Up @@ -833,6 +834,12 @@ declare type ReadableStreamPipeToOptions = PipeToOptions;

declare type ReadableStreamReadResult<T = any> = { done: true; value: undefined; } | { done: false; value: T; };

declare class ReadableStreamReadableStreamAsyncIterator {
constructor(underlyingSource?: Object, queuingStrategy?: Object);
next(): Promise<ReadableStreamReadResult<any>>;
return(reason?: any): Promise<ReadableStreamReadResult<any>>;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Would be good to make all stream types generic at some point.

}

/**
* Back-compat alias.
* @deprecated Use ReadableStreamBYOBReader
Expand All @@ -850,6 +857,10 @@ interface ReadableStreamTransform {
readable: ReadableStream;
}

interface ReadableStreamValuesOptions {
preventCancel?: boolean;
}

declare class Request extends Body {
constructor(input: Request | string, init?: RequestInit | Request);
clone(): Request;
Expand Down
103 changes: 103 additions & 0 deletions src/workers.json
Original file line number Diff line number Diff line change
Expand Up @@ -6930,6 +6930,23 @@
]
}
}
},
{
"name": "values",
"type": {
"params": [
{
"name": "options",
"type": {
"name": "ReadableStreamValuesOptions",
"optional": true
}
}
],
"returns": {
"name": "ReadableStreamReadableStreamAsyncIterator"
}
}
}
],
"kind": "class"
Expand Down Expand Up @@ -7346,6 +7363,79 @@
],
"kind": "typedef"
},
"ReadableStreamReadableStreamAsyncIterator": {
"name": "ReadableStreamReadableStreamAsyncIterator",
"members": [
{
"name": "constructor",
"type": {
"params": [
{
"name": "underlyingSource",
"type": {
"name": "Object",
"optional": true
}
},
{
"name": "queuingStrategy",
"type": {
"name": "Object",
"optional": true
}
}
]
}
},
{
"name": "next",
"type": {
"params": [],
"returns": {
"name": "Promise",
"args": [
{
"name": "ReadableStreamReadResult",
"args": [
{
"name": "any"
}
]
}
]
}
}
},
{
"name": "return",
"type": {
"params": [
{
"name": "reason",
"type": {
"name": "any",
"optional": true
}
}
],
"returns": {
"name": "Promise",
"args": [
{
"name": "ReadableStreamReadResult",
"args": [
{
"name": "any"
}
]
}
]
}
}
}
],
"kind": "class"
},
"ReadableStreamReadableStreamBYOBReader": {
"name": "ReadableStreamReadableStreamBYOBReader",
"type": {
Expand Down Expand Up @@ -7386,6 +7476,19 @@
],
"kind": "struct"
},
"ReadableStreamValuesOptions": {
"name": "ReadableStreamValuesOptions",
"members": [
{
"name": "preventCancel",
"type": {
"name": "boolean",
"optional": true
}
}
],
"kind": "struct"
},
"Request": {
"name": "Request",
"members": [
Expand Down