Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore(knowledgbe/blog): removed deprecated knowledgebase #4999

Merged
merged 6 commits into from
Jan 10, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
30 changes: 15 additions & 15 deletions locale/en/docs/guides/blocking-vs-non-blocking.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ layout: docs.hbs
This overview covers the difference between **blocking** and **non-blocking**
calls in Node.js. This overview will refer to the event loop and libuv but no
prior knowledge of those topics is required. Readers are assumed to have a
basic understanding of the JavaScript language and Node.js [callback pattern](/en/knowledge/getting-started/control-flow/what-are-callbacks/).
basic understanding of the JavaScript language and Node.js callback pattern.

> "I/O" refers primarily to interaction with the system's disk and
> network supported by [libuv](https://libuv.org/).
Expand Down Expand Up @@ -39,15 +39,15 @@ execute **asynchronously**.
Using the File System module as an example, this is a **synchronous** file read:

```js
const fs = require('fs');
const data = fs.readFileSync('/file.md'); // blocks here until file is read
const fs = require("fs");
const data = fs.readFileSync("/file.md"); // blocks here until file is read
```

And here is an equivalent **asynchronous** example:

```js
const fs = require('fs');
fs.readFile('/file.md', (err, data) => {
const fs = require("fs");
fs.readFile("/file.md", (err, data) => {
if (err) throw err;
});
```
Expand All @@ -62,17 +62,17 @@ shown.
Let's expand our example a little bit:

```js
const fs = require('fs');
const data = fs.readFileSync('/file.md'); // blocks here until file is read
const fs = require("fs");
const data = fs.readFileSync("/file.md"); // blocks here until file is read
console.log(data);
moreWork(); // will run after console.log
```

And here is a similar, but not equivalent asynchronous example:

```js
const fs = require('fs');
fs.readFile('/file.md', (err, data) => {
const fs = require("fs");
fs.readFile("/file.md", (err, data) => {
if (err) throw err;
console.log(data);
});
Expand Down Expand Up @@ -109,12 +109,12 @@ There are some patterns that should be avoided when dealing with I/O. Let's look
at an example:

```js
const fs = require('fs');
fs.readFile('/file.md', (err, data) => {
const fs = require("fs");
fs.readFile("/file.md", (err, data) => {
if (err) throw err;
console.log(data);
});
fs.unlinkSync('/file.md');
fs.unlinkSync("/file.md");
```

In the above example, `fs.unlinkSync()` is likely to be run before
Expand All @@ -123,11 +123,11 @@ better way to write this, which is completely **non-blocking** and guaranteed to
execute in the correct order is:

```js
const fs = require('fs');
fs.readFile('/file.md', (readFileErr, data) => {
const fs = require("fs");
fs.readFile("/file.md", (readFileErr, data) => {
if (readFileErr) throw readFileErr;
console.log(data);
fs.unlink('/file.md', (unlinkErr) => {
fs.unlink("/file.md", (unlinkErr) => {
if (unlinkErr) throw unlinkErr;
});
});
Expand Down

This file was deleted.

This file was deleted.

42 changes: 0 additions & 42 deletions locale/en/knowledge/HTTP/servers/how-to-create-a-HTTP-server.md

This file was deleted.

This file was deleted.

This file was deleted.

Loading