mirror of
https://github.com/denoland/deno.git
synced 2024-11-21 15:04:11 -05:00
parent
f45ceb2320
commit
4122c8f164
1 changed files with 85 additions and 0 deletions
85
ext/fetch/lib.deno_fetch.d.ts
vendored
85
ext/fetch/lib.deno_fetch.d.ts
vendored
|
@ -405,3 +405,88 @@ declare function fetch(
|
|||
input: URL | Request | string,
|
||||
init?: RequestInit,
|
||||
): Promise<Response>;
|
||||
|
||||
/**
|
||||
* @category Fetch API
|
||||
*/
|
||||
declare interface EventSourceInit {
|
||||
withCredentials?: boolean;
|
||||
}
|
||||
|
||||
/**
|
||||
* @category Fetch API
|
||||
*/
|
||||
declare interface EventSourceEventMap {
|
||||
"error": Event;
|
||||
"message": MessageEvent;
|
||||
"open": Event;
|
||||
}
|
||||
|
||||
/**
|
||||
* @category Fetch API
|
||||
*/
|
||||
declare interface EventSource extends EventTarget {
|
||||
onerror: ((this: EventSource, ev: Event) => any) | null;
|
||||
onmessage: ((this: EventSource, ev: MessageEvent) => any) | null;
|
||||
onopen: ((this: EventSource, ev: Event) => any) | null;
|
||||
/**
|
||||
* Returns the state of this EventSource object's connection. It can have the values described below.
|
||||
*/
|
||||
readonly readyState: number;
|
||||
/**
|
||||
* Returns the URL providing the event stream.
|
||||
*/
|
||||
readonly url: string;
|
||||
/**
|
||||
* Returns true if the credentials mode for connection requests to the URL providing the event stream is set to "include", and false otherwise.
|
||||
*/
|
||||
readonly withCredentials: boolean;
|
||||
/**
|
||||
* Aborts any instances of the fetch algorithm started for this EventSource object, and sets the readyState attribute to CLOSED.
|
||||
*/
|
||||
close(): void;
|
||||
readonly CONNECTING: 0;
|
||||
readonly OPEN: 1;
|
||||
readonly CLOSED: 2;
|
||||
addEventListener<K extends keyof EventSourceEventMap>(
|
||||
type: K,
|
||||
listener: (this: EventSource, ev: EventSourceEventMap[K]) => any,
|
||||
options?: boolean | AddEventListenerOptions,
|
||||
): void;
|
||||
addEventListener(
|
||||
type: string,
|
||||
listener: (this: EventSource, event: MessageEvent) => any,
|
||||
options?: boolean | AddEventListenerOptions,
|
||||
): void;
|
||||
addEventListener(
|
||||
type: string,
|
||||
listener: EventListenerOrEventListenerObject,
|
||||
options?: boolean | AddEventListenerOptions,
|
||||
): void;
|
||||
removeEventListener<K extends keyof EventSourceEventMap>(
|
||||
type: K,
|
||||
listener: (this: EventSource, ev: EventSourceEventMap[K]) => any,
|
||||
options?: boolean | EventListenerOptions,
|
||||
): void;
|
||||
removeEventListener(
|
||||
type: string,
|
||||
listener: (this: EventSource, event: MessageEvent) => any,
|
||||
options?: boolean | EventListenerOptions,
|
||||
): void;
|
||||
removeEventListener(
|
||||
type: string,
|
||||
listener: EventListenerOrEventListenerObject,
|
||||
options?: boolean | EventListenerOptions,
|
||||
): void;
|
||||
}
|
||||
|
||||
/**
|
||||
* @category Fetch API
|
||||
*/
|
||||
declare var EventSource: {
|
||||
prototype: EventSource;
|
||||
new (url: string | URL, eventSourceInitDict?: EventSourceInit): EventSource;
|
||||
readonly CONNECTING: 0;
|
||||
readonly OPEN: 1;
|
||||
readonly CLOSED: 2;
|
||||
};
|
||||
|
|
Loading…
Reference in a new issue