Merge pull request #2614 from jonathanlu31/patch-1

Fix grammar
This commit is contained in:
Ilya Kantor 2022-01-21 14:06:35 +03:00 committed by GitHub
commit 1dc6dfbc7c
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
3 changed files with 9 additions and 9 deletions

View file

@ -196,9 +196,9 @@ So the single `callback` function is used both for reporting errors and passing
## Pyramid of Doom
From the first look, it's a viable way of asynchronous coding. And indeed it is. For one or maybe two nested calls it looks fine.
At first glance, it looks like a viable approach to asynchronous coding. And indeed it is. For one or maybe two nested calls it looks fine.
But for multiple asynchronous actions that follow one after another we'll have code like this:
But for multiple asynchronous actions that follow one after another, we'll have code like this:
```js
loadScript('1.js', function(error, script) {
@ -229,8 +229,8 @@ loadScript('1.js', function(error, script) {
```
In the code above:
1. We load `1.js`, then if there's no error.
2. We load `2.js`, then if there's no error.
1. We load `1.js`, then if there's no error...
2. We load `2.js`, then if there's no error...
3. We load `3.js`, then if there's no error -- do something else `(*)`.
As calls become more nested, the code becomes deeper and increasingly more difficult to manage, especially if we have real code instead of `...` that may include more loops, conditional statements and so on.
@ -299,7 +299,7 @@ function step3(error, script) {
}
```
See? It does the same, and there's no deep nesting now because we made every action a separate top-level function.
See? It does the same thing, and there's no deep nesting now because we made every action a separate top-level function.
It works, but the code looks like a torn apart spreadsheet. It's difficult to read, and you probably noticed that one needs to eye-jump between pieces while reading it. That's inconvenient, especially if the reader is not familiar with the code and doesn't know where to eye-jump.