Skip to content

Commit 9b3b2d6

Browse files
committed
Fix code style
1 parent 4e5cbc7 commit 9b3b2d6

File tree

5 files changed

+13
-13
lines changed

5 files changed

+13
-13
lines changed

JavaScript/1-get.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ const http = require('http');
44

55
const url = 'http://ietf.org/';
66

7-
http.get(url, res => {
7+
http.get(url, (res) => {
88
console.log(res.req._header);
99
console.dir(res.headers);
1010
if (res.statusCode !== 200) {
@@ -14,7 +14,7 @@ http.get(url, res => {
1414
}
1515
res.setEncoding('utf8');
1616
const buffer = [];
17-
res.on('data', chunk => {
17+
res.on('data', (chunk) => {
1818
buffer.push(chunk);
1919
});
2020
res.on('end', () => {

JavaScript/2-get-https.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ const fs = require('fs');
55

66
const url = 'https://ietf.org/';
77

8-
https.get(url, res => {
8+
https.get(url, (res) => {
99
console.log(res.req._header);
1010
console.dir(res.headers);
1111
if (res.statusCode !== 200) {
@@ -15,7 +15,7 @@ https.get(url, res => {
1515
}
1616
res.setEncoding('utf8');
1717
const buffer = [];
18-
res.on('data', chunk => {
18+
res.on('data', (chunk) => {
1919
buffer.push(chunk);
2020
});
2121
res.on('end', () => {

JavaScript/3-fetch.js

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -3,22 +3,22 @@
33
const http = require('http');
44
const https = require('https');
55

6-
const fetch = url => new Promise((resolve, reject) => {
6+
const fetch = (url) => new Promise((resolve, reject) => {
77
const protocol = url.startsWith('https') ? https : http;
8-
protocol.get(url, res => {
8+
protocol.get(url, (res) => {
99
if (res.statusCode !== 200) {
1010
const { statusCode, statusMessage } = res;
1111
reject(new Error(`Status Code: ${statusCode} ${statusMessage}`));
1212
}
1313
res.setEncoding('utf8');
1414
const buffer = [];
15-
res.on('data', chunk => buffer.push(chunk));
15+
res.on('data', (chunk) => buffer.push(chunk));
1616
res.on('end', () => resolve(buffer.join()));
1717
});
1818
});
1919

2020
// Usage
2121

2222
fetch('http://ietf.org/')
23-
.then(body => console.log(body))
24-
.catch(err => console.error(err));
23+
.then((body) => console.log(body))
24+
.catch((err) => console.error(err));

JavaScript/6-api.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,13 +9,13 @@ const ajax = (base, methods) => {
99
const callback = args.pop();
1010
const url = base + method + '/' + args.join('/');
1111
console.log(url);
12-
http.get(url, res => {
12+
http.get(url, (res) => {
1313
if (res.statusCode !== 200) {
1414
callback(new Error(`Status Code: ${res.statusCode}`));
1515
return;
1616
}
1717
const buffer = [];
18-
res.on('data', chunk => buffer.push(chunk));
18+
res.on('data', (chunk) => buffer.push(chunk));
1919
res.on('end', () => callback(null, JSON.parse(buffer.join())));
2020
});
2121
};

JavaScript/6-server.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,8 @@ const users = {
88
};
99

1010
const routing = {
11-
'/api/user': name => users[name],
12-
'/api/userBorn': name => users[name].born
11+
'/api/user': (name) => users[name],
12+
'/api/userBorn': (name) => users[name].born
1313
};
1414

1515
http.createServer((req, res) => {

0 commit comments

Comments
 (0)