From b4dd9f41919bbe7efe99a7d6b9d1a1322a61037f Mon Sep 17 00:00:00 2001 From: Tom Wanzek Date: Tue, 27 Mar 2018 11:12:31 -0400 Subject: [PATCH] feat(d3-fetch): update to minor version 1.1 * Update d3-fetch to minor version 1.1. * Add `html(...)` * Add `svg(...)` * Add `xml(...)` Closes #24516 --- types/d3-fetch/d3-fetch-tests.ts | 11 +++++++++++ types/d3-fetch/index.d.ts | 34 ++++++++++++++++++++++++++++++-- 2 files changed, 43 insertions(+), 2 deletions(-) diff --git a/types/d3-fetch/d3-fetch-tests.ts b/types/d3-fetch/d3-fetch-tests.ts index 941955c996..3cffde0c9e 100644 --- a/types/d3-fetch/d3-fetch-tests.ts +++ b/types/d3-fetch/d3-fetch-tests.ts @@ -49,3 +49,14 @@ promise1 = d3Fetch.tsv(url); promise1 = d3Fetch.tsv(url, init); promise2 = d3Fetch.tsv(url, parseRow); promise2 = d3Fetch.tsv(url, init, parseRow); + +let docPromise: Promise; +docPromise = d3Fetch.hmtl(url); +docPromise = d3Fetch.hmtl(url, init); + +docPromise = d3Fetch.svg(url); +docPromise = d3Fetch.svg(url, init); + +let xmlDocPromise: Promise; +xmlDocPromise = d3Fetch.xml(url); +xmlDocPromise = d3Fetch.xml(url, init); diff --git a/types/d3-fetch/index.d.ts b/types/d3-fetch/index.d.ts index 3eb11ce48a..fc0d5e0e66 100644 --- a/types/d3-fetch/index.d.ts +++ b/types/d3-fetch/index.d.ts @@ -1,10 +1,10 @@ -// Type definitions for d3-fetch 1.0 +// Type definitions for d3-fetch 1.1 // Project: https://d3js.org/d3-fetch/ // Definitions by: Hugues Stefanski // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped // TypeScript Version: 2.2 -// Last module patch version validated against: 1.0.1 +// Last module patch version validated against: 1.1.0 import { DSVParsedArray, DSVRowString, DSVRowAny } from 'd3-dsv'; @@ -146,6 +146,16 @@ export function dsv( row: (rawRow: DSVRowString, index: number, columns: string[]) => ParsedRow | undefined | null ): Promise>; +/** + * Fetches the file at the specified input URL as text, parses it as HTML and returns a Promise of an HTML DOM Document. + * + * If init is specified, it is passed along to the underlying call to fetch. + * + * @param url A valid URL string. + * @param init An optional request initialization object. + */ +export function hmtl(url: string, init?: RequestInit): Promise; + /** * Fetches the image at the specified input URL and returns a promise of an HTML image element. * @@ -168,6 +178,16 @@ export function image(url: string, init?: {[key: string]: any}): Promise(url: string, init?: RequestInit): Promise; +/** + * Fetches the file at the specified input URL as text, parses it as SVG and returns a Promise of an SVG Document. + * + * If init is specified, it is passed along to the underlying call to fetch. + * + * @param url A valid URL string. + * @param init An optional request initialization object. + */ +export function svg(url: string, init?: RequestInit): Promise; + /** * Fetches the text file at the specified input URL and returns it as a Promise of a string. * @@ -234,3 +254,13 @@ export function tsv( init: RequestInit, row: (rawRow: DSVRowString, index: number, columns: string[]) => ParsedRow | undefined | null ): Promise>; + +/** + * Fetches the file at the specified input URL as text, parses it as XML and returns a Promise of an XML Document. + * + * If init is specified, it is passed along to the underlying call to fetch. + * + * @param url A valid URL string. + * @param init An optional request initialization object. + */ +export function xml(url: string, init?: RequestInit): Promise;