1
1
/**
2
2
* Fetching content from the web is environment-specific, so Ethers
3
- * provides an abstraction the each environment can implement to provide
3
+ * provides an abstraction that each environment can implement to provide
4
4
* this service.
5
5
*
6
6
* On [Node.js](link-node), the ``http`` and ``https`` libs are used to
7
7
* create a request object, register event listeners and process data
8
8
* and populate the [[FetchResponse]].
9
9
*
10
10
* In a browser, the [DOM fetch](link-js-fetch) is used, and the resulting
11
- * ``Promise`` is waited on to retreive the payload.
11
+ * ``Promise`` is waited on to retrieve the payload.
12
12
*
13
13
* The [[FetchRequest]] is responsible for handling many common situations,
14
- * such as redirects, server throttling, authentcation , etc.
14
+ * such as redirects, server throttling, authentication , etc.
15
15
*
16
16
* It also handles common gateways, such as IPFS and data URIs.
17
17
*
@@ -26,7 +26,7 @@ import { toUtf8Bytes, toUtf8String } from "./utf8.js"
26
26
import { createGetUrl } from "./geturl.js" ;
27
27
28
28
/**
29
- * An environments implementation of ``getUrl`` must return this type.
29
+ * An environment's implementation of ``getUrl`` must return this type.
30
30
*/
31
31
export type GetUrlResponse = {
32
32
statusCode : number ,
@@ -204,7 +204,7 @@ export class FetchRequest implements Iterable<[ key: string, value: string ]> {
204
204
#getUrlFunc: null | FetchGetUrlFunc ;
205
205
206
206
/**
207
- * The fetch URI to requrest .
207
+ * The fetch URL to request .
208
208
*/
209
209
get url ( ) : string { return this . #url; }
210
210
set url ( url : string ) {
@@ -219,15 +219,15 @@ export class FetchRequest implements Iterable<[ key: string, value: string ]> {
219
219
* header.
220
220
*
221
221
* If %%body%% is null, the body is cleared (along with the
222
- * intrinsic ``Content-Type``) and the .
222
+ * intrinsic ``Content-Type``).
223
223
*
224
- * If %%body%% is a string, the intrincis ``Content-Type`` is set to
224
+ * If %%body%% is a string, the intrinsic ``Content-Type`` is set to
225
225
* ``text/plain``.
226
226
*
227
- * If %%body%% is a Uint8Array, the intrincis ``Content-Type`` is set to
227
+ * If %%body%% is a Uint8Array, the intrinsic ``Content-Type`` is set to
228
228
* ``application/octet-stream``.
229
229
*
230
- * If %%body%% is any other object, the intrincis ``Content-Type`` is
230
+ * If %%body%% is any other object, the intrinsic ``Content-Type`` is
231
231
* set to ``application/json``.
232
232
*/
233
233
get body ( ) : null | Uint8Array {
@@ -278,7 +278,7 @@ export class FetchRequest implements Iterable<[ key: string, value: string ]> {
278
278
* The headers that will be used when requesting the URI. All
279
279
* keys are lower-case.
280
280
*
281
- * This object is a copy, so any chnages will **NOT** be reflected
281
+ * This object is a copy, so any changes will **NOT** be reflected
282
282
* in the ``FetchRequest``.
283
283
*
284
284
* To set a header entry, use the ``setHeader`` method.
@@ -381,7 +381,7 @@ export class FetchRequest implements Iterable<[ key: string, value: string ]> {
381
381
}
382
382
383
383
/**
384
- * The timeout (in milliseconds) to wait for a complere response.
384
+ * The timeout (in milliseconds) to wait for a complete response.
385
385
* //(default: 5 minutes)//
386
386
*/
387
387
get timeout ( ) : number { return this . #timeout; }
@@ -610,7 +610,7 @@ export class FetchRequest implements Iterable<[ key: string, value: string ]> {
610
610
* to %%location%%.
611
611
*/
612
612
redirect ( location : string ) : FetchRequest {
613
- // Redirection; for now we only support absolute locataions
613
+ // Redirection; for now we only support absolute locations
614
614
const current = this . url . split ( ":" ) [ 0 ] . toLowerCase ( ) ;
615
615
const target = location . split ( ":" ) [ 0 ] . toLowerCase ( ) ;
616
616
@@ -764,7 +764,7 @@ interface ThrottleError extends Error {
764
764
} ;
765
765
766
766
/**
767
- * The response for a FetchREquest .
767
+ * The response for a FetchRequest .
768
768
*/
769
769
export class FetchResponse implements Iterable < [ key : string , value : string ] > {
770
770
#statusCode: number ;
@@ -909,7 +909,7 @@ export class FetchResponse implements Iterable<[ key: string, value: string ]> {
909
909
}
910
910
911
911
/**
912
- * Returns true of the response has a body.
912
+ * Returns true if the response has a body.
913
913
*/
914
914
hasBody ( ) : this is ( FetchResponse & { body : Uint8Array } ) {
915
915
return ( this . #body != null ) ;
0 commit comments