summaryrefslogtreecommitdiff
path: root/cli/js/lib.deno.shared_globals.d.ts
diff options
context:
space:
mode:
authorYusuke Sakurai <kerokerokerop@gmail.com>2020-04-04 03:55:23 +0900
committerGitHub <noreply@github.com>2020-04-03 14:55:23 -0400
commit24261744857df3cca8c9e05f07cc85c0346a6751 (patch)
tree257edb6bc9c88bd879ef27cba77c040e7cd648c3 /cli/js/lib.deno.shared_globals.d.ts
parentcb0acfe305a0f2f13773f41a038d8a919c3730ae (diff)
feat: Expose ReadableStream and make Blob more standardized (#4581)
Co-authored-by: crowlkats <crowlkats@gmail.com>
Diffstat (limited to 'cli/js/lib.deno.shared_globals.d.ts')
-rw-r--r--cli/js/lib.deno.shared_globals.d.ts33
1 files changed, 33 insertions, 0 deletions
diff --git a/cli/js/lib.deno.shared_globals.d.ts b/cli/js/lib.deno.shared_globals.d.ts
index 565121bea..5fec86311 100644
--- a/cli/js/lib.deno.shared_globals.d.ts
+++ b/cli/js/lib.deno.shared_globals.d.ts
@@ -34,6 +34,7 @@ declare interface WindowOrWorkerGlobalScope {
FormData: __domTypes.FormDataConstructor;
TextEncoder: typeof __textEncoding.TextEncoder;
TextDecoder: typeof __textEncoding.TextDecoder;
+ ReadableStream: __domTypes.ReadableStreamConstructor;
Request: __domTypes.RequestConstructor;
Response: typeof __fetch.Response;
performance: __performanceUtil.Performance;
@@ -250,6 +251,7 @@ declare const location: __domTypes.Location;
declare const FormData: __domTypes.FormDataConstructor;
declare const TextEncoder: typeof __textEncoding.TextEncoder;
declare const TextDecoder: typeof __textEncoding.TextDecoder;
+declare const ReadableStream: __domTypes.ReadableStreamConstructor;
declare const Request: __domTypes.RequestConstructor;
declare const Response: typeof __fetch.Response;
declare const performance: __performanceUtil.Performance;
@@ -282,6 +284,7 @@ declare type Headers = __domTypes.Headers;
declare type FormData = __domTypes.FormData;
declare type TextEncoder = __textEncoding.TextEncoder;
declare type TextDecoder = __textEncoding.TextDecoder;
+declare type ReadableStream<R = any> = __domTypes.ReadableStream<R>;
declare type Request = __domTypes.Request;
declare type Response = __domTypes.Response;
declare type Worker = __workers.Worker;
@@ -551,6 +554,27 @@ declare namespace __domTypes {
preventClose?: boolean;
signal?: AbortSignal;
}
+ export interface UnderlyingSource<R = any> {
+ cancel?: ReadableStreamErrorCallback;
+ pull?: ReadableStreamDefaultControllerCallback<R>;
+ start?: ReadableStreamDefaultControllerCallback<R>;
+ type?: undefined;
+ }
+ export interface ReadableStreamErrorCallback {
+ (reason: any): void | PromiseLike<void>;
+ }
+
+ export interface ReadableStreamDefaultControllerCallback<R> {
+ (controller: ReadableStreamDefaultController<R>): void | PromiseLike<void>;
+ }
+
+ export interface ReadableStreamDefaultController<R> {
+ readonly desiredSize: number;
+ enqueue(chunk?: R): void;
+ close(): void;
+ error(e?: any): void;
+ }
+
/** This Streams API interface represents a readable stream of byte data. The
* Fetch API offers a concrete instance of a ReadableStream through the body
* property of a Response object. */
@@ -574,6 +598,12 @@ declare namespace __domTypes {
*/
tee(): [ReadableStream<R>, ReadableStream<R>];
}
+
+ export interface ReadableStreamConstructor<R = any> {
+ new (src?: UnderlyingSource<R>): ReadableStream<R>;
+ prototype: ReadableStream<R>;
+ }
+
export interface ReadableStreamReader<R = any> {
cancel(reason: any): Promise<void>;
read(): Promise<ReadableStreamReadResult<R>>;
@@ -939,6 +969,9 @@ declare namespace __blob {
options?: __domTypes.BlobPropertyBag
);
slice(start?: number, end?: number, contentType?: string): DenoBlob;
+ stream(): __domTypes.ReadableStream<Uint8Array>;
+ text(): Promise<string>;
+ arrayBuffer(): Promise<ArrayBuffer>;
}
}