-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
28 changed files
with
4,271 additions
and
20 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
16 changes: 0 additions & 16 deletions
16
...nous-control-flow-patterns-with-callbacks/02-web-spider-callback-discipline/utils.test.js
This file was deleted.
Oops, something went wrong.
11 changes: 11 additions & 0 deletions
11
...chronous-control-flow-patterns-with-callbacks/03-sequential-execution/README.md
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
# 03-sequential-execution | ||
|
||
Simple example that demonstrates sequential tasks using callbacks | ||
|
||
## Run | ||
|
||
Run: | ||
|
||
```bash | ||
node index.js | ||
``` |
26 changes: 26 additions & 0 deletions
26
04-asynchronous-control-flow-patterns-with-callbacks/03-sequential-execution/index.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
function asyncOperation(cb) { | ||
process.nextTick(cb) | ||
} | ||
|
||
function task1(cb) { | ||
asyncOperation(() => { | ||
task2(cb) | ||
}) | ||
} | ||
|
||
function task2(cb) { | ||
asyncOperation(() => { | ||
task3(cb) | ||
}) | ||
} | ||
|
||
function task3(cb) { | ||
asyncOperation(() => { | ||
cb() // finally executes the callback | ||
}) | ||
} | ||
|
||
task1(() => { | ||
// executed when task1, task2 and task3 are completed | ||
console.log('tasks 1, 2 and 3 executed') | ||
}) |
16 changes: 16 additions & 0 deletions
16
04-asynchronous-control-flow-patterns-with-callbacks/03-sequential-execution/package.json
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
{ | ||
"name": "03-sequential-execution", | ||
"version": "1.0.0", | ||
"description": "Simple example that demonstrates sequential tasks using callbacks", | ||
"engines": { | ||
"node": ">=22" | ||
}, | ||
"engineStrict": true, | ||
"type": "module", | ||
"scripts": { | ||
"test": "echo \"Error: no test specified\" && exit 1" | ||
}, | ||
"keywords": [], | ||
"author": "", | ||
"license": "ISC" | ||
} |
11 changes: 11 additions & 0 deletions
11
04-asynchronous-control-flow-patterns-with-callbacks/04-web-spider-v2/README.md
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
# 04-web-spider-v2 | ||
|
||
Web spider example to demonstrate sequential iteration | ||
|
||
## Run | ||
|
||
Install the necessary dependencies with `npm install` and then run: | ||
|
||
```bash | ||
node spider-cli.js https://loige.co | ||
``` |
Oops, something went wrong.