Skip to content

Commit 8c197f8

Browse files
andrew-healeyRichienb
authored andcommitted
docs: Fix typos and grammatical errors in README.md (node-fetch#686)
1 parent 1e99050 commit 8c197f8

File tree

1 file changed

+22
-22
lines changed

1 file changed

+22
-22
lines changed

README.md

Lines changed: 22 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -51,17 +51,17 @@ A light-weight module that brings `window.fetch` to Node.js
5151

5252
## Motivation
5353

54-
Instead of implementing `XMLHttpRequest` in Node.js to run browser-specific [Fetch polyfill](https://github.com/github/fetch), why not go from native `http` to `fetch` API directly? Hence `node-fetch`, minimal code for a `window.fetch` compatible API on Node.js runtime.
54+
Instead of implementing `XMLHttpRequest` in Node.js to run browser-specific [Fetch polyfill](https://github.com/github/fetch), why not go from native `http` to `fetch` API directly? Hence, `node-fetch`, minimal code for a `window.fetch` compatible API on Node.js runtime.
5555

5656
See Matt Andrews' [isomorphic-fetch](https://github.com/matthew-andrews/isomorphic-fetch) or Leonardo Quixada's [cross-fetch](https://github.com/lquixada/cross-fetch) for isomorphic usage (exports `node-fetch` for server-side, `whatwg-fetch` for client-side).
5757

5858
## Features
5959

6060
- Stay consistent with `window.fetch` API.
6161
- Make conscious trade-off when following [WHATWG fetch spec][whatwg-fetch] and [stream spec](https://streams.spec.whatwg.org/) implementation details, document known differences.
62-
- Use native promise, but allow substituting it with [insert your favorite promise library].
63-
- Use native Node streams for body, on both request and response.
64-
- Decode content encoding (gzip/deflate) properly, and convert string output (such as `res.text()` and `res.json()`) to UTF-8 automatically.
62+
- Use native promise but allow substituting it with [insert your favorite promise library].
63+
- Use native Node streams for body on both request and response.
64+
- Decode content encoding (gzip/deflate) properly and convert string output (such as `res.text()` and `res.json()`) to UTF-8 automatically.
6565
- Useful extensions such as timeout, redirect limit, response size limit, [explicit errors](ERROR-HANDLING.md) for troubleshooting.
6666

6767
## Difference from client-side fetch
@@ -79,12 +79,12 @@ $ npm install node-fetch
7979
```
8080

8181
## Loading and configuring the module
82-
We suggest you load the module via `require`, pending the stabalizing of es modules in node:
82+
We suggest you load the module via `require` until the stabilization of ES modules in node:
8383
```js
8484
const fetch = require('node-fetch');
8585
```
8686

87-
If you are using a Promise library other than native, set it through fetch.Promise:
87+
If you are using a Promise library other than native, set it through `fetch.Promise`:
8888
```js
8989
const Bluebird = require('bluebird');
9090

@@ -93,7 +93,7 @@ fetch.Promise = Bluebird;
9393

9494
## Common Usage
9595

96-
NOTE: The documentation below is up-to-date with `2.x` releases, [see `1.x` readme](https://github.com/bitinn/node-fetch/blob/1.x/README.md), [changelog](https://github.com/bitinn/node-fetch/blob/1.x/CHANGELOG.md) and [2.x upgrade guide](UPGRADE-GUIDE.md) for the differences.
96+
NOTE: The documentation below is up-to-date with `2.x` releases; see the [`1.x` readme](https://github.com/bitinn/node-fetch/blob/1.x/README.md), [changelog](https://github.com/bitinn/node-fetch/blob/1.x/CHANGELOG.md) and [2.x upgrade guide](UPGRADE-GUIDE.md) for the differences.
9797

9898
#### Plain text or HTML
9999
```js
@@ -149,9 +149,9 @@ fetch('https://httpbin.org/post', { method: 'POST', body: params })
149149
```
150150

151151
#### Handling exceptions
152-
NOTE: 3xx-5xx responses are *NOT* exceptions, and should be handled in `then()`, see the next section.
152+
NOTE: 3xx-5xx responses are *NOT* exceptions and should be handled in `then()`; see the next section for more information.
153153

154-
Adding a catch to the fetch promise chain will catch *all* exceptions, such as errors originating from node core libraries, like network errors, and operational errors which are instances of FetchError. See the [error handling document](ERROR-HANDLING.md) for more details.
154+
Adding a catch to the fetch promise chain will catch *all* exceptions, such as errors originating from node core libraries, network errors and operational errors, which are instances of FetchError. See the [error handling document](ERROR-HANDLING.md) for more details.
155155

156156
```js
157157
fetch('https://domain.invalid/')
@@ -189,7 +189,7 @@ fetch('https://assets-cdn.github.com/images/modules/logos_page/Octocat.png')
189189
```
190190

191191
#### Buffer
192-
If you prefer to cache binary data in full, use buffer(). (NOTE: buffer() is a `node-fetch` only API)
192+
If you prefer to cache binary data in full, use buffer(). (NOTE: `buffer()` is a `node-fetch`-only API)
193193

194194
```js
195195
const fileType = require('file-type');
@@ -214,7 +214,7 @@ fetch('https://github.com/')
214214

215215
#### Extract Set-Cookie Header
216216

217-
Unlike browsers, you can access raw `Set-Cookie` headers manually using `Headers.raw()`, this is a `node-fetch` only API.
217+
Unlike browsers, you can access raw `Set-Cookie` headers manually using `Headers.raw()`. This is a `node-fetch` only API.
218218

219219
```js
220220
fetch(url).then(res => {
@@ -266,11 +266,11 @@ fetch('https://httpbin.org/post', options)
266266

267267
#### Request cancellation with AbortSignal
268268

269-
> NOTE: You may only cancel streamed requests on Node >= v8.0.0
269+
> NOTE: You may cancel streamed requests only on Node >= v8.0.0
270270
271271
You may cancel requests with `AbortController`. A suggested implementation is [`abort-controller`](https://www.npmjs.com/package/abort-controller).
272272

273-
An example of timing out a request after 150ms could be achieved as follows:
273+
An example of timing out a request after 150ms could be achieved as the following:
274274

275275
```js
276276
import AbortController from 'abort-controller';
@@ -311,7 +311,7 @@ See [test cases](https://github.com/bitinn/node-fetch/blob/master/test/test.js)
311311

312312
Perform an HTTP(S) fetch.
313313

314-
`url` should be an absolute url, such as `https://example.com/`. A path-relative URL (`/file/under/root`) or protocol-relative URL (`//can-be-http-or-https.com/`) will result in a rejected promise.
314+
`url` should be an absolute url, such as `https://example.com/`. A path-relative URL (`/file/under/root`) or protocol-relative URL (`//can-be-http-or-https.com/`) will result in a rejected `Promise`.
315315

316316
<a id="fetch-options"></a>
317317
### Options
@@ -353,15 +353,15 @@ Note: when `body` is a `Stream`, `Content-Length` is not set automatically.
353353

354354
##### Custom Agent
355355

356-
The `agent` option allows you to specify networking related options that's out of the scope of Fetch. Including and not limit to:
356+
The `agent` option allows you to specify networking related options which are out of the scope of Fetch, including and not limited to the following:
357357

358358
- Support self-signed certificate
359359
- Use only IPv4 or IPv6
360360
- Custom DNS Lookup
361361

362362
See [`http.Agent`](https://nodejs.org/api/http.html#http_new_agent_options) for more information.
363363

364-
In addition, `agent` option accepts a function that returns http(s).Agent instance given current [URL](https://nodejs.org/api/url.html), this is useful during a redirection chain across HTTP and HTTPS protocol.
364+
In addition, the `agent` option accepts a function that returns `http`(s)`.Agent` instance given current [URL](https://nodejs.org/api/url.html), this is useful during a redirection chain across HTTP and HTTPS protocol.
365365

366366
```js
367367
const httpAgent = new http.Agent({
@@ -435,7 +435,7 @@ The following properties are not implemented in node-fetch at this moment:
435435

436436
<small>*(spec-compliant)*</small>
437437

438-
- `body` A string or [Readable stream][node-readable]
438+
- `body` A `String` or [`Readable` stream][node-readable]
439439
- `options` A [`ResponseInit`][response-init] options dictionary
440440

441441
Constructs a new `Response` object. The constructor is identical to that in the [browser](https://developer.mozilla.org/en-US/docs/Web/API/Response/Response).
@@ -465,7 +465,7 @@ This class allows manipulating and iterating over a set of HTTP headers. All met
465465

466466
- `init` Optional argument to pre-fill the `Headers` object
467467

468-
Construct a new `Headers` object. `init` can be either `null`, a `Headers` object, an key-value map object, or any iterable object.
468+
Construct a new `Headers` object. `init` can be either `null`, a `Headers` object, an key-value map object or any iterable object.
469469

470470
```js
471471
// Example adapted from https://fetch.spec.whatwg.org/#example-headers-class
@@ -506,15 +506,15 @@ The following methods are not yet implemented in node-fetch at this moment:
506506

507507
* Node.js [`Readable` stream][node-readable]
508508

509-
The data encapsulated in the `Body` object. Note that while the [Fetch Standard][whatwg-fetch] requires the property to always be a WHATWG `ReadableStream`, in node-fetch it is a Node.js [`Readable` stream][node-readable].
509+
Data are encapsulated in the `Body` object. Note that while the [Fetch Standard][whatwg-fetch] requires the property to always be a WHATWG `ReadableStream`, in node-fetch it is a Node.js [`Readable` stream][node-readable].
510510

511511
#### body.bodyUsed
512512

513513
<small>*(spec-compliant)*</small>
514514

515515
* `Boolean`
516516

517-
A boolean property for if this body has been consumed. Per spec, a consumed body cannot be used again.
517+
A boolean property for if this body has been consumed. Per the specs, a consumed body cannot be used again.
518518

519519
#### body.arrayBuffer()
520520
#### body.blob()
@@ -541,9 +541,9 @@ Consume the body and return a promise that will resolve to a Buffer.
541541

542542
* Returns: <code>Promise&lt;String&gt;</code>
543543

544-
Identical to `body.text()`, except instead of always converting to UTF-8, encoding sniffing will be performed and text converted to UTF-8, if possible.
544+
Identical to `body.text()`, except instead of always converting to UTF-8, encoding sniffing will be performed and text converted to UTF-8 if possible.
545545

546-
(This API requires an optional dependency on npm package [encoding](https://www.npmjs.com/package/encoding), which you need to install manually. `webpack` users may see [a warning message](https://github.com/bitinn/node-fetch/issues/412#issuecomment-379007792) due to this optional dependency.)
546+
(This API requires an optional dependency of the npm package [encoding](https://www.npmjs.com/package/encoding), which you need to install manually. `webpack` users may see [a warning message](https://github.com/bitinn/node-fetch/issues/412#issuecomment-379007792) due to this optional dependency.)
547547

548548
<a id="class-fetcherror"></a>
549549
### Class: FetchError

0 commit comments

Comments
 (0)