mirror of
https://github.com/gosticks/DefinitelyTyped.git
synced 2026-12-03 03:31:47 +00:00
Completed fetch API
This commit is contained in:
@@ -0,0 +1,15 @@
|
||||
import * as d3Fetch from 'd3-fetch';
|
||||
|
||||
interface MyType {
|
||||
foo: string;
|
||||
}
|
||||
|
||||
let promise: Promise<MyType>;
|
||||
const url = 'foo.bar';
|
||||
|
||||
const init: RequestInit = {};
|
||||
|
||||
promise = d3Fetch.blob<MyType>(url);
|
||||
promise = d3Fetch.blob<MyType>(url, init);
|
||||
promise = d3Fetch.buffer<MyType>(url);
|
||||
promise = d3Fetch.buffer<MyType>(url, init);
|
||||
|
||||
Vendored
+42
@@ -3,3 +3,45 @@
|
||||
// Definitions by: Hugues Stefanski <https://github.com/ledragon>
|
||||
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
|
||||
|
||||
/**Fetches the binary file at the specified input URL as a Blob. */
|
||||
export function blob<ResponseData>(input: string): Promise<ResponseData>;
|
||||
/**Fetches the binary file at the specified input URL as a Blob. Passes init along to the underlying call to fetch. */
|
||||
export function blob<ResponseData>(input: string, init: RequestInit): Promise<ResponseData>;
|
||||
/**Fetches the binary file at the specified input URL as an ArrayBuffer. */
|
||||
export function buffer<ResponseData>(input: string): Promise<ResponseData>;
|
||||
/**Fetches the binary file at the specified input URL as an ArrayBuffer. Passes init along to the underlying call to fetch. */
|
||||
export function buffer<ResponseData>(input: string, init: RequestInit): Promise<ResponseData>;
|
||||
|
||||
/**Equivalent to d3.dsv with the comma character as the delimiter. */
|
||||
export function csv<ResponseData>(input: string): Promise<ResponseData>;
|
||||
/**Equivalent to d3.dsv with the comma character as the delimiter. */
|
||||
export function csv<ResponseData>(input: string, init: RequestInit): Promise<ResponseData>;
|
||||
/**Equivalent to d3.dsv with the comma character as the delimiter. */
|
||||
export function csv<ResponseData>(input: string, init: RequestInit, row: (d: any) => any): Promise<ResponseData>;
|
||||
|
||||
/**Fetches the DSV file at the specified input URL. */
|
||||
export function dsv<ResponseData>(delimiter: string, input: string): Promise<ResponseData>;
|
||||
export function dsv<ResponseData>(delimiter: string, input: string, init: RequestInit): Promise<ResponseData>;
|
||||
export function dsv<ResponseData>(delimiter: string, input: string, init: RequestInit, row: any): Promise<ResponseData>;
|
||||
|
||||
/**Fetches the image at the specified input URL. */
|
||||
export function image<ResponseData>(input: string): Promise<ResponseData>;
|
||||
/**Fetches the image at the specified input URL. Passes init along to the underlying call to fetch. */
|
||||
export function image<ResponseData>(input: string, init: RequestInit): Promise<ResponseData>;
|
||||
|
||||
/**Fetches the json file at the specified input URL. */
|
||||
export function json<ResponseData>(input: string): Promise<ResponseData>;
|
||||
/**Fetches the json file at the specified input URL. Passes init along to the underlying call to fetch. */
|
||||
export function json<ResponseData>(input: string, init: RequestInit): Promise<ResponseData>;
|
||||
|
||||
/**Fetches the text file at the specified input URL. */
|
||||
export function text(input: string): Promise<string>;
|
||||
/**Fetches the text file at the specified input URL. Passes init along to the underlying call to fetch. */
|
||||
export function text(input: string, init: RequestInit): Promise<string>;
|
||||
|
||||
/**Equivalent to d3.dsv with the tab character as the delimiter. */
|
||||
export function tsv<ResponseData>(input: string): Promise<ResponseData>;
|
||||
/**Equivalent to d3.dsv with the tab character as the delimiter. */
|
||||
export function tsv<ResponseData>(input: string, init: RequestInit): Promise<ResponseData>;
|
||||
/**Equivalent to d3.dsv with the tab character as the delimiter. */
|
||||
export function tsv<ResponseData>(input: string, init: RequestInit, row: (d: any) => any): Promise<ResponseData>;
|
||||
|
||||
@@ -2,7 +2,8 @@
|
||||
"compilerOptions": {
|
||||
"module": "commonjs",
|
||||
"lib": [
|
||||
"es6"
|
||||
"es2017",
|
||||
"dom"
|
||||
],
|
||||
"noImplicitAny": true,
|
||||
"noImplicitThis": true,
|
||||
|
||||
Reference in New Issue
Block a user