docs: fixed typos in Fetch jsdocs (#4355)
This commit is contained in:
parent
e9fac926c9
commit
168518f1cb
@ -1,6 +1,6 @@
|
|||||||
/**
|
/**
|
||||||
* Fetching content from the web is environment-specific, so Ethers
|
* Fetching content from the web is environment-specific, so Ethers
|
||||||
* provides an abstraction the each environment can implement to provide
|
* provides an abstraction that each environment can implement to provide
|
||||||
* this service.
|
* this service.
|
||||||
*
|
*
|
||||||
* On [Node.js](link-node), the ``http`` and ``https`` libs are used to
|
* On [Node.js](link-node), the ``http`` and ``https`` libs are used to
|
||||||
@ -8,10 +8,10 @@
|
|||||||
* and populate the [[FetchResponse]].
|
* and populate the [[FetchResponse]].
|
||||||
*
|
*
|
||||||
* In a browser, the [DOM fetch](link-js-fetch) is used, and the resulting
|
* In a browser, the [DOM fetch](link-js-fetch) is used, and the resulting
|
||||||
* ``Promise`` is waited on to retreive the payload.
|
* ``Promise`` is waited on to retrieve the payload.
|
||||||
*
|
*
|
||||||
* The [[FetchRequest]] is responsible for handling many common situations,
|
* The [[FetchRequest]] is responsible for handling many common situations,
|
||||||
* such as redirects, server throttling, authentcation, etc.
|
* such as redirects, server throttling, authentication, etc.
|
||||||
*
|
*
|
||||||
* It also handles common gateways, such as IPFS and data URIs.
|
* It also handles common gateways, such as IPFS and data URIs.
|
||||||
*
|
*
|
||||||
@ -26,7 +26,7 @@ import { toUtf8Bytes, toUtf8String } from "./utf8.js"
|
|||||||
import { createGetUrl } from "./geturl.js";
|
import { createGetUrl } from "./geturl.js";
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* An environments implementation of ``getUrl`` must return this type.
|
* An environment's implementation of ``getUrl`` must return this type.
|
||||||
*/
|
*/
|
||||||
export type GetUrlResponse = {
|
export type GetUrlResponse = {
|
||||||
statusCode: number,
|
statusCode: number,
|
||||||
@ -204,7 +204,7 @@ export class FetchRequest implements Iterable<[ key: string, value: string ]> {
|
|||||||
#getUrlFunc: null | FetchGetUrlFunc;
|
#getUrlFunc: null | FetchGetUrlFunc;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The fetch URI to requrest.
|
* The fetch URL to request.
|
||||||
*/
|
*/
|
||||||
get url(): string { return this.#url; }
|
get url(): string { return this.#url; }
|
||||||
set url(url: string) {
|
set url(url: string) {
|
||||||
@ -219,15 +219,15 @@ export class FetchRequest implements Iterable<[ key: string, value: string ]> {
|
|||||||
* header.
|
* header.
|
||||||
*
|
*
|
||||||
* If %%body%% is null, the body is cleared (along with the
|
* If %%body%% is null, the body is cleared (along with the
|
||||||
* intrinsic ``Content-Type``) and the .
|
* intrinsic ``Content-Type``).
|
||||||
*
|
*
|
||||||
* If %%body%% is a string, the intrincis ``Content-Type`` is set to
|
* If %%body%% is a string, the intrinsic ``Content-Type`` is set to
|
||||||
* ``text/plain``.
|
* ``text/plain``.
|
||||||
*
|
*
|
||||||
* If %%body%% is a Uint8Array, the intrincis ``Content-Type`` is set to
|
* If %%body%% is a Uint8Array, the intrinsic ``Content-Type`` is set to
|
||||||
* ``application/octet-stream``.
|
* ``application/octet-stream``.
|
||||||
*
|
*
|
||||||
* If %%body%% is any other object, the intrincis ``Content-Type`` is
|
* If %%body%% is any other object, the intrinsic ``Content-Type`` is
|
||||||
* set to ``application/json``.
|
* set to ``application/json``.
|
||||||
*/
|
*/
|
||||||
get body(): null | Uint8Array {
|
get body(): null | Uint8Array {
|
||||||
@ -278,7 +278,7 @@ export class FetchRequest implements Iterable<[ key: string, value: string ]> {
|
|||||||
* The headers that will be used when requesting the URI. All
|
* The headers that will be used when requesting the URI. All
|
||||||
* keys are lower-case.
|
* keys are lower-case.
|
||||||
*
|
*
|
||||||
* This object is a copy, so any chnages will **NOT** be reflected
|
* This object is a copy, so any changes will **NOT** be reflected
|
||||||
* in the ``FetchRequest``.
|
* in the ``FetchRequest``.
|
||||||
*
|
*
|
||||||
* To set a header entry, use the ``setHeader`` method.
|
* To set a header entry, use the ``setHeader`` method.
|
||||||
@ -381,7 +381,7 @@ export class FetchRequest implements Iterable<[ key: string, value: string ]> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The timeout (in milliseconds) to wait for a complere response.
|
* The timeout (in milliseconds) to wait for a complete response.
|
||||||
* //(default: 5 minutes)//
|
* //(default: 5 minutes)//
|
||||||
*/
|
*/
|
||||||
get timeout(): number { return this.#timeout; }
|
get timeout(): number { return this.#timeout; }
|
||||||
@ -610,7 +610,7 @@ export class FetchRequest implements Iterable<[ key: string, value: string ]> {
|
|||||||
* to %%location%%.
|
* to %%location%%.
|
||||||
*/
|
*/
|
||||||
redirect(location: string): FetchRequest {
|
redirect(location: string): FetchRequest {
|
||||||
// Redirection; for now we only support absolute locataions
|
// Redirection; for now we only support absolute locations
|
||||||
const current = this.url.split(":")[0].toLowerCase();
|
const current = this.url.split(":")[0].toLowerCase();
|
||||||
const target = location.split(":")[0].toLowerCase();
|
const target = location.split(":")[0].toLowerCase();
|
||||||
|
|
||||||
@ -764,7 +764,7 @@ interface ThrottleError extends Error {
|
|||||||
};
|
};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The response for a FetchREquest.
|
* The response for a FetchRequest.
|
||||||
*/
|
*/
|
||||||
export class FetchResponse implements Iterable<[ key: string, value: string ]> {
|
export class FetchResponse implements Iterable<[ key: string, value: string ]> {
|
||||||
#statusCode: number;
|
#statusCode: number;
|
||||||
@ -909,7 +909,7 @@ export class FetchResponse implements Iterable<[ key: string, value: string ]> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns true of the response has a body.
|
* Returns true if the response has a body.
|
||||||
*/
|
*/
|
||||||
hasBody(): this is (FetchResponse & { body: Uint8Array }) {
|
hasBody(): this is (FetchResponse & { body: Uint8Array }) {
|
||||||
return (this.#body != null);
|
return (this.#body != null);
|
||||||
|
Loading…
Reference in New Issue
Block a user