@types/d3-request

  • Version 1.0.9
  • Published
  • 18.3 kB
  • 1 dependency
  • MIT license

Install

npm i @types/d3-request
yarn add @types/d3-request
pnpm add @types/d3-request

Overview

TypeScript definitions for d3-request

Index

Functions

function csv

csv: {
(url: string): DsvRequest;
(
url: string,
callback: (
this: DsvRequest,
error: any,
d: DSVParsedArray<DSVRowString>
) => void
): DsvRequest;
<ParsedRow extends object>(
url: string,
row: (rawRow: DSVRowString, index: number, columns: string[]) => ParsedRow,
callback: (
this: DsvRequest,
error: any,
d: DSVParsedArray<ParsedRow>
) => void
): DsvRequest;
};
  • Returns a new request for the CSV file at the specified url with the default mime type text/csv.

  • Returns a new request for the CSV file at the specified url with the default mime type text/csv. And send a GET request.

  • Returns a new request for the CSV file at the specified url with the default mime type text/csv. And send a GET request. Use a row conversion function to map and filter row objects to a more-specific representation; see dsv.parse for details.

function html

html: {
(url: string): Request;
(
url: string,
callback: (this: Request, error: any, d: DocumentFragment) => void
): Request;
};
  • Returns a new request for the HTML file at the specified url with the default mime type text/html. The HTML file is returned as a document fragment.

  • Returns a new request for the HTML file at the specified url with the default mime type text/html. The HTML file is returned as a document fragment. And send a GET request.

function json

json: {
(url: string): Request;
<ParsedObject extends { [key: string]: any }>(
url: string,
callback: (this: Request, error: any, d: ParsedObject) => void
): Request;
};
  • Returns a new request to get the JSON file at the specified url with the default mime type application/json.

  • Returns a new request to get the JSON file at the specified url with the default mime type application/json. And send a GET request.

function request

request: {
(url: string): Request;
(
url: string,
callback: (this: Request, error: any, d: XMLHttpRequest) => void
): Request;
};
  • Returns a new request for specified url. The returned request is not yet sent and can be further configured.

    See d3.json, d3.csv, d3.tsv, d3.text, d3.html and d3.xml for content-specific convenience constructors.

  • Returns a new request for specified url. It is equivalent to calling request.get immediately after construction: d3.request(url).get(callback). And send a GET request.

    If you wish to specify a request header or a mime type, you must not specify a callback to the constructor. Use request.header or request.mimeType followed by request.get instead.

    See d3.json, d3.csv, d3.tsv, d3.text, d3.html and d3.xml for content-specific convenience constructors.

function text

text: {
(url: string): Request;
(url: string, callback: (this: Request, error: any, d: string) => void): Request;
};
  • Returns a new request to get the text file at the specified url with the default mime type text/plain.

  • Returns a new request to get the text file at the specified url with the default mime type text/plain. And send a GET request.

function tsv

tsv: {
(url: string): DsvRequest;
(
url: string,
callback: (
this: DsvRequest,
error: any,
d: DSVParsedArray<DSVRowString>
) => void
): DsvRequest;
<ParsedRow extends object>(
url: string,
row: (rawRow: DSVRowString, index: number, columns: string[]) => ParsedRow,
callback: (
this: DsvRequest,
error: any,
d: DSVParsedArray<ParsedRow>
) => void
): DsvRequest;
};
  • Returns a new request for a TSV file at the specified url with the default mime type text/tab-separated-values.

  • Returns a new request for a TSV file at the specified url with the default mime type text/tab-separated-values. And send a GET request.

  • Returns a new request for a TSV file at the specified url with the default mime type text/tab-separated-values. And send a GET request. Use a row conversion function to map and filter row objects to a more-specific representation; see dsv.parse for details.

function xml

xml: {
(url: string): Request;
(url: string, callback: (this: Request, error: any, d: any) => void): Request;
};
  • Returns a new request to get the XML file at the specified url with the default mime type application/xml.

  • Returns a new request to get the XML file at the specified url with the default mime type application/xml. And send a GET request.

Interfaces

interface DsvRequest

interface DsvRequest extends Request {}

    method row

    row: <ParsedRow extends object>(
    value: (rawRow: DSVRowString, index: number, columns: string[]) => ParsedRow
    ) => DsvRequest;

      interface Request

      interface Request {}

        method abort

        abort: () => this;
        • Aborts this request, if it is currently in-flight, and returns this request instance. See XMLHttpRequest’s abort.

        method get

        get: {
        (): this;
        <RequestData>(data: RequestData): this;
        <ResponseData>(callback: (error: any, d: ResponseData) => void): this;
        <RequestData, ResponseData>(
        data: RequestData,
        callback: (error: any, d: ResponseData) => void
        ): this;
        };
        • Equivalent to request.send with the GET method: request.send("GET").

        • Equivalent to request.send with the GET method: request.send("GET", data).

        • Equivalent to request.send with the GET method: request.send("GET", callback).

        • Equivalent to request.send with the GET method: request.send("GET", data, callback).

        method header

        header: { (name: string): string; (name: string, value: string): this };
        • Returns the current value of the request header with the specified name. Header names are case-insensitive.

        • Sets the request header with the specified name to the specified value and returns this request instance. If value is null, removes the request header with the specified name instead. Header names are case-insensitive.

          Request headers can only be modified before the request is sent. Therefore, you cannot pass a callback to the request constructor if you wish to specify a header; use request.get or similar instead.

        method mimeType

        mimeType: { (): string | null; (value: string): this };
        • Returns the current mime type, which defaults to null.

        • Sets the request mime type to the specified value and returns this request instance. If type is null, clears the current mime type (if any) instead.

          The mime type is used to both set the "Accept" request header and for overrideMimeType, where supported.

          The request mime type can only be modified before the request is sent. Therefore, you cannot pass a callback to the request constructor if you wish to override the mime type; use request.get or similar instead.

        method on

        on: {
        (type: 'beforesend'): (this: this, xhr: XMLHttpRequest) => void;
        (type: 'progress'): (
        this: this,
        progressEvent: ProgressEvent<EventTarget>
        ) => void;
        (type: 'error'): (this: this, error: any) => void;
        <ResponseData>(type: 'load'): (this: this, data: ResponseData) => void;
        (type: string): (this: this, data: any) => void;
        (type: string, listener: null): this;
        (
        type: 'beforesend',
        listener: (this: this, xhr: XMLHttpRequest) => void
        ): this;
        (
        type: 'progress',
        listener: (this: this, progressEvent: ProgressEvent<EventTarget>) => void
        ): this;
        (type: 'error', listener: (this: this, error: any) => void): this;
        <ResponseData>(
        type: 'load',
        listener: (this: this, data: ResponseData) => void
        ): this;
        (type: string, listener: (this: this, data: any) => void): this;
        };
        • Returns the currently-assigned listener for the "beforesend" type, if any.

        • Returns the currently-assigned listener for the "progress" type, if any.

        • Returns the currently-assigned listener for the "error" type, if any.

        • Returns the currently-assigned listener for the "load" type, if any.

        • Returns the currently-assigned listener for the specified type, if any.

        • Removes the current event listener for the specified type, if any.

        • Sets the event listener for the "beforesend" type, to allow custom headers and the like to be set before the request is sent, and returns this request instance.

          If an event listener was already registered for the same type, the existing listener is removed before the new listener is added. To register multiple listeners for the same type, the type may be followed by an optional name, such as beforesend.foo. See d3-dispatch for details.

        • Sets the event listener for the "progress" type, to monitor the progress of the request, and returns this request instance.

          If an event listener was already registered for the same type, the existing listener is removed before the new listener is added. To register multiple listeners for the same type, the type may be followed by an optional name, such as progress.foo. See d3-dispatch for details.

        • Sets the event listener for the "error" type, when the request completes unsuccessfully; this includes 4xx and 5xx response codes, and returns this request instance.

          If an event listener was already registered for the same type, the existing listener is removed before the new listener is added. To register multiple listeners for the same type, the type may be followed by an optional name, such as error.foo. See d3-dispatch for details.

        • Sets the event listener for the "load" type, when the request completes successfully, and returns this request instance.

          If an event listener was already registered for the same type, the existing listener is removed before the new listener is added. To register multiple listeners for the same type, the type may be followed by an optional name, such as load.foo. See d3-dispatch for details.

        • Sets the event listener for the specified type, and returns this request instance.

          The type must be one of the following: "beforesend", "progress", "load", "error".

          If an event listener was already registered for the same type, the existing listener is removed before the new listener is added. To register multiple listeners for the same type, the type may be followed by an optional name, such as load.foo. See d3-dispatch for details.

        method password

        password: { (): string | null; (value: string): this };
        • Returns the current password, which defaults to null.

        • Sets the password for authentication to the specified string and returns this request instance.

        method post

        post: {
        (): this;
        <RequestData>(data: RequestData): this;
        <ResponseData>(
        callback: (this: this, error: any, d: ResponseData) => void
        ): this;
        <RequestData, ResponseData>(
        data: RequestData,
        callback: (this: this, error: any, d: ResponseData) => void
        ): this;
        };
        • Equivalent to request.send with the POST method: request.send("POST").

        • Equivalent to request.send with the POST method: request.send("POST", data).

        • Equivalent to request.send with the POST method: request.send("POST", callback).

        • Equivalent to request.send with the POST method: request.send("POST", data, callback).

        method response

        response: <ResponseData>(
        callback: (this: this, response: XMLHttpRequest) => ResponseData
        ) => this;
        • Sets the response value function to the specified function and returns this request instance. The response value function is used to map the response XMLHttpRequest object to a useful data value. See the convenience methods json and text for examples.

        method responseType

        responseType: {
        (): XMLHttpRequestResponseType | undefined;
        (value: XMLHttpRequestResponseType): this;
        };
        • Returns the current response type, which defaults to `` (the empty string).

        • Sets the response type attribute of the request and returns this request instance. Typical values are: `` (the empty string), arraybuffer, blob, document, and text.

        method send

        send: {
        (method: string): this;
        <RequestData>(method: string, data: RequestData): this;
        <ResponseData>(
        method: string,
        callback: (this: this, error: any, d: ResponseData) => void
        ): this;
        <RequestData, ResponseData>(
        method: string,
        data: RequestData,
        callback: (this: this, error: any, d: ResponseData) => void
        ): this;
        };
        • Issues this request using the specified method (such as GET or POST).

          The listeners "load" and "error" should be registered via request.on.

        • Issues this request using the specified method (such as GET or POST), posting the specified data in the request body, and returns this request instance.

          The listeners "load" and "error" should be registered via request.on.

        • Issues this request using the specified method (such as GET or POST) and returns this request instance. The callback will be invoked asynchronously when the request succeeds or fails. The callback is invoked with two arguments: the error, if any, and the response value. The response value is undefined if an error occurs.

        • Issues this request using the specified method (such as GET or POST), posting the specified data in the request body, and returns this request instance. The callback will be invoked asynchronously when the request succeeds or fails. The callback is invoked with two arguments: the error, if any, and the response value. The response value is undefined if an error occurs.

        method timeout

        timeout: { (): number; (value: number): this };
        • Returns the current response timeout, which defaults to 0.

        • Sets the timeout attribute of the request to the specified number of milliseconds and returns this request instance.

        method user

        user: { (): string | null; (value: string): this };
        • Returns the current user name, which defaults to null.

        • Sets the user name for authentication to the specified string and returns this request instance.

        Package Files (1)

        Dependencies (1)

        Dev Dependencies (0)

        No dev dependencies.

        Peer Dependencies (0)

        No peer dependencies.

        Badge

        To add a badge like this onejsDocs.io badgeto your package's README, use the codes available below.

        You may also use Shields.io to create a custom badge linking to https://www.jsdocs.io/package/@types/d3-request.

        • Markdown
          [![jsDocs.io](https://img.shields.io/badge/jsDocs.io-reference-blue)](https://www.jsdocs.io/package/@types/d3-request)
        • HTML
          <a href="https://www.jsdocs.io/package/@types/d3-request"><img src="https://img.shields.io/badge/jsDocs.io-reference-blue" alt="jsDocs.io"></a>