Skip to content

Commit

Permalink
fix: add missing DOM types
Browse files Browse the repository at this point in the history
  • Loading branch information
jasonkuhrt committed May 29, 2020
1 parent 3b25f6d commit 4b02516
Showing 1 changed file with 44 additions and 0 deletions.
44 changes: 44 additions & 0 deletions src/types.dom.ts
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,25 @@ interface ReadableStream<R = any> {
tee(): [ReadableStream<R>, ReadableStream<R>]
}

interface ReadableStreamBYOBReader {
readonly closed: Promise<void>
cancel(reason?: any): Promise<void>
read<T extends ArrayBufferView>(view: T): Promise<ReadableStreamReadResult<T>>
releaseLock(): void
}

type ReadableStreamReadResult<T> = ReadableStreamReadValueResult<T> | ReadableStreamReadDoneResult<T>

interface ReadableStreamReadDoneResult<T> {
done: true
value?: T
}

interface ReadableStreamReadValueResult<T> {
done: false
value: T
}

interface ReadableStreamDefaultReader<R = any> {
readonly closed: Promise<void>
cancel(reason?: any): Promise<void>
Expand Down Expand Up @@ -401,3 +420,28 @@ export interface Request extends Body {
}

// declare function fetch(input?: Request | string, init?: any): Promise<any>

/** This Streams API interface provides a standard abstraction for writing streaming data to a destination, known as a sink. This object comes with built-in backpressure and queuing. */
interface WritableStream<W = any> {
readonly locked: boolean
abort(reason?: any): Promise<void>
getWriter(): WritableStreamDefaultWriter<W>
}

/** This Streams API interface is the object returned by WritableStream.getWriter() and once created locks the < writer to the WritableStream ensuring that no other streams can write to the underlying sink. */
interface WritableStreamDefaultWriter<W = any> {
readonly closed: Promise<void>
readonly desiredSize: number | null
readonly ready: Promise<void>
abort(reason?: any): Promise<void>
close(): Promise<void>
releaseLock(): void
write(chunk: W): Promise<void>
}

interface PipeOptions {
preventAbort?: boolean
preventCancel?: boolean
preventClose?: boolean
signal?: AbortSignal
}

0 comments on commit 4b02516

Please # to comment.