mirror of
https://github.com/gosticks/DefinitelyTyped.git
synced 2026-12-03 11:41:44 +00:00
Merge branch 'd3-fetch'
This commit is contained in:
@@ -0,0 +1,39 @@
|
||||
import * as d3Fetch from 'd3-fetch';
|
||||
import { DSVParsedArray, DSVRowString, DSVRowAny } from 'd3-dsv';
|
||||
|
||||
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);
|
||||
promise = d3Fetch.image<MyType>(url);
|
||||
promise = d3Fetch.image<MyType>(url, init);
|
||||
promise = d3Fetch.json<MyType>(url);
|
||||
promise = d3Fetch.json<MyType>(url, init);
|
||||
|
||||
let myString: Promise<string>;
|
||||
myString = d3Fetch.text(url);
|
||||
myString = d3Fetch.text(url, init);
|
||||
|
||||
const parseRow = (d: {}) => {
|
||||
const myType: MyType = { foo: 'foo' };
|
||||
return myType;
|
||||
};
|
||||
let promise2: Promise<DSVParsedArray<MyType>>;
|
||||
promise2 = d3Fetch.csv<MyType>(url);
|
||||
promise2 = d3Fetch.csv<MyType>(url, init);
|
||||
promise2 = d3Fetch.csv<MyType>(url, init, parseRow);
|
||||
promise2 = d3Fetch.dsv<MyType>(';', url);
|
||||
promise2 = d3Fetch.dsv<MyType>(';', url, init);
|
||||
promise2 = d3Fetch.dsv<MyType>(';', url, init, parseRow);
|
||||
promise2 = d3Fetch.tsv<MyType>(url);
|
||||
promise2 = d3Fetch.tsv<MyType>(url, init);
|
||||
promise2 = d3Fetch.tsv<MyType>(url, init, parseRow);
|
||||
Vendored
+64
@@ -0,0 +1,64 @@
|
||||
// Type definitions for d3-fetch 1.0.1
|
||||
// Project: https://d3js.org/d3-fetch/
|
||||
// Definitions by: Hugues Stefanski <https://github.com/ledragon>
|
||||
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
|
||||
|
||||
import { DSVParsedArray, DSVRowString, DSVRowAny } from 'd3-dsv';
|
||||
|
||||
/**Fetches the binary file at the specified input URL as a Blob. */
|
||||
export function blob<ResponseData>(url: 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>(url: string, init: RequestInit): Promise<ResponseData>;
|
||||
/**Fetches the binary file at the specified input URL as an ArrayBuffer. */
|
||||
export function buffer<ResponseData>(url: 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>(url: string, init: RequestInit): Promise<ResponseData>;
|
||||
|
||||
/**Equivalent to d3.dsv with the comma character as the delimiter. */
|
||||
export function csv<ParsedRow extends DSVRowAny>(url: string): Promise<DSVParsedArray<ParsedRow>>;
|
||||
/**Equivalent to d3.dsv with the comma character as the delimiter. */
|
||||
export function csv<ParsedRow extends DSVRowAny>(url: string, init: RequestInit): Promise<DSVParsedArray<ParsedRow>>;
|
||||
/**Equivalent to d3.dsv with the comma character as the delimiter. */
|
||||
export function csv<ParsedRow extends DSVRowAny>(
|
||||
url: string,
|
||||
init: RequestInit,
|
||||
row: (d: DSVRowAny) => ParsedRow
|
||||
): Promise<DSVParsedArray<ParsedRow>>;
|
||||
|
||||
/**Fetches the DSV file at the specified input URL. */
|
||||
export function dsv<ParsedRow extends DSVRowAny>(delimiter: string, url: string): Promise<DSVParsedArray<ParsedRow>>;
|
||||
/**Fetches the DSV file at the specified input URL. */
|
||||
export function dsv<ParsedRow extends DSVRowAny>(delimiter: string, url: string, init: RequestInit): Promise<DSVParsedArray<ParsedRow>>;
|
||||
/**Fetches the DSV file at the specified input URL. */
|
||||
export function dsv<ParsedRow extends DSVRowAny>(
|
||||
delimiter: string,
|
||||
url: string,
|
||||
init: RequestInit,
|
||||
row: (d: DSVRowAny) => ParsedRow
|
||||
): Promise<DSVParsedArray<ParsedRow>>;
|
||||
|
||||
/**Fetches the image at the specified input URL. */
|
||||
export function image<ResponseData>(url: string): Promise<ResponseData>;
|
||||
/**Fetches the image at the specified input URL. Passes init along to the underlying call to fetch. */
|
||||
export function image<ResponseData>(url: string, init: RequestInit): Promise<ResponseData>;
|
||||
|
||||
/**Fetches the json file at the specified input URL. */
|
||||
export function json<ResponseData>(url: 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>(url: string, init: RequestInit): Promise<ResponseData>;
|
||||
|
||||
/**Fetches the text file at the specified input URL. */
|
||||
export function text(url: string): Promise<string>;
|
||||
/**Fetches the text file at the specified input URL. Passes init along to the underlying call to fetch. */
|
||||
export function text(url: string, init: RequestInit): Promise<string>;
|
||||
|
||||
/**Equivalent to d3.dsv with the tab character as the delimiter. */
|
||||
export function tsv<ParsedRow extends DSVRowAny>(url: string): Promise<DSVParsedArray<ParsedRow>>;
|
||||
/**Equivalent to d3.dsv with the tab character as the delimiter. */
|
||||
export function tsv<ParsedRow extends DSVRowAny>(url: string, init: RequestInit): Promise<DSVParsedArray<ParsedRow>>;
|
||||
/**Equivalent to d3.dsv with the tab character as the delimiter. */
|
||||
export function tsv<ParsedRow extends DSVRowAny>(
|
||||
url: string,
|
||||
init: RequestInit,
|
||||
row: (d: DSVRowAny) => ParsedRow
|
||||
): Promise<DSVParsedArray<ParsedRow>>;
|
||||
@@ -0,0 +1,23 @@
|
||||
{
|
||||
"compilerOptions": {
|
||||
"module": "commonjs",
|
||||
"lib": [
|
||||
"es2017",
|
||||
"dom"
|
||||
],
|
||||
"noImplicitAny": true,
|
||||
"noImplicitThis": true,
|
||||
"strictNullChecks": true,
|
||||
"baseUrl": "../",
|
||||
"typeRoots": [
|
||||
"../"
|
||||
],
|
||||
"types": [],
|
||||
"noEmit": true,
|
||||
"forceConsistentCasingInFileNames": true
|
||||
},
|
||||
"files": [
|
||||
"index.d.ts",
|
||||
"d3-fetch-tests.ts"
|
||||
]
|
||||
}
|
||||
@@ -0,0 +1 @@
|
||||
{ "extends": "dtslint/dt.json" }
|
||||
Reference in New Issue
Block a user