Skip to content

Commit 5c9f35b

Browse files
committed
prettified
1 parent 1bebaaa commit 5c9f35b

34 files changed

+110
-125
lines changed

prettier.config.js

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
module.exports = {
2+
printWidth: 100,
3+
singleQuote: true,
4+
trailingComma: 'all',
5+
bracketSpacing: true,
6+
jsxBracketSameLine: false,
7+
tabWidth: 2,
8+
semi: true,
9+
};

src/functions/1-functions-sync.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
'use strict';
22

33
const campbellsTomatoSoup = {
4-
brand: 'Campbell\'s',
5-
contents: 'tomato soup'
4+
brand: "Campbell's",
5+
contents: 'tomato soup',
66
};
77

88
function say(message) {
@@ -34,7 +34,7 @@ function eatLunch(foodCan) {
3434
}
3535

3636
function main() {
37-
say('It\'s lunch time!');
37+
say("It's lunch time!");
3838
eatLunch(campbellsTomatoSoup);
3939
say('Finished lunch,');
4040
}

src/functions/2-functions-callback.js

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,8 @@
33
const { startTimer, stopTimer } = require('./timer');
44

55
const campbellsTomatoSoup = {
6-
brand: 'Campbell\'s',
7-
contents: 'tomato soup'
6+
brand: "Campbell's",
7+
contents: 'tomato soup',
88
};
99

1010
function say(message) {
@@ -37,15 +37,15 @@ function eat(food, onFinished) {
3737
}
3838

3939
function eatLunch(foodCan, onFinished) {
40-
openCan(foodCan, (contents) => {
41-
warmUp(contents, (hotFood) => {
40+
openCan(foodCan, contents => {
41+
warmUp(contents, hotFood => {
4242
eat(hotFood, onFinished);
4343
});
4444
});
4545
}
4646

4747
function main() {
48-
say('It\'s lunch time!');
48+
say("It's lunch time!");
4949
startTimer(counter => say(counter));
5050
eatLunch(campbellsTomatoSoup, () => {
5151
stopTimer();

src/functions/3-functions-promise.js

Lines changed: 10 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,8 @@
33
const { startTimer, stopTimer } = require('./timer');
44

55
const campbellsTomatoSoup = {
6-
brand: 'Campbell\'s',
7-
contents: 'tomato soup'
6+
brand: "Campbell's",
7+
contents: 'tomato soup',
88
};
99

1010
function say(message) {
@@ -14,7 +14,7 @@ function say(message) {
1414
function openCan(foodCan) {
1515
const { brand, contents } = foodCan;
1616
say(`Using can opener to open a can of ${brand} ${contents}.`);
17-
return new Promise((resolve) => {
17+
return new Promise(resolve => {
1818
setTimeout(() => {
1919
say(`Opened the can of ${contents}.`);
2020
resolve(contents);
@@ -24,7 +24,7 @@ function openCan(foodCan) {
2424

2525
function warmUp(food) {
2626
say(`Warming up the ${food}.`);
27-
return new Promise((resolve) => {
27+
return new Promise(resolve => {
2828
setTimeout(() => {
2929
say(`Warmed up the ${food}.`);
3030
resolve('hot ' + food);
@@ -33,7 +33,7 @@ function warmUp(food) {
3333
}
3434

3535
function eat(food) {
36-
return new Promise((resolve) => {
36+
return new Promise(resolve => {
3737
say(`Eating the ${food}.`);
3838
setTimeout(() => {
3939
say(`Finished the ${food}.`);
@@ -49,13 +49,12 @@ function eatLunch(foodCan) {
4949
}
5050

5151
function main() {
52-
say('It\'s lunch time!');
52+
say("It's lunch time!");
5353
startTimer(counter => say(counter));
54-
eatLunch(campbellsTomatoSoup)
55-
.then(() => {
56-
stopTimer();
57-
say('Finished lunch');
58-
});
54+
eatLunch(campbellsTomatoSoup).then(() => {
55+
stopTimer();
56+
say('Finished lunch');
57+
});
5958
}
6059

6160
main();

src/functions/4-functions-promise-dry.js

Lines changed: 16 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,8 @@
33
const { startTimer, stopTimer } = require('./timer');
44

55
const campbellsTomatoSoup = {
6-
brand: 'Campbell\'s',
7-
contents: 'tomato soup'
6+
brand: "Campbell's",
7+
contents: 'tomato soup',
88
};
99

1010
function say(message) {
@@ -18,26 +18,23 @@ function wait(delaySecs) {
1818
function openCan(foodCan) {
1919
const { brand, contents } = foodCan;
2020
say(`Using can opener to open a can of ${brand} ${contents}.`);
21-
return wait(2)
22-
.then(() => {
23-
say(`Opened the can of ${contents}.`);
24-
return contents;
25-
});
21+
return wait(2).then(() => {
22+
say(`Opened the can of ${contents}.`);
23+
return contents;
24+
});
2625
}
2726

2827
function warmUp(food) {
2928
say(`Warming up the ${food}.`);
30-
return wait(4)
31-
.then(() => {
32-
say(`Warmed up the ${food}.`);
33-
return 'hot ' + food;
34-
});
29+
return wait(4).then(() => {
30+
say(`Warmed up the ${food}.`);
31+
return 'hot ' + food;
32+
});
3533
}
3634

3735
function eat(food) {
3836
say(`Eating the ${food}.`);
39-
return wait(4)
40-
.then(() => say(`Finished the ${food}.`));
37+
return wait(4).then(() => say(`Finished the ${food}.`));
4138
}
4239

4340
function eatLunch(foodCan) {
@@ -47,13 +44,12 @@ function eatLunch(foodCan) {
4744
}
4845

4946
function main() {
50-
say('It\'s lunch time!');
47+
say("It's lunch time!");
5148
startTimer(counter => say(counter));
52-
eatLunch(campbellsTomatoSoup)
53-
.then(() => {
54-
stopTimer();
55-
say('Finished lunch');
56-
});
49+
eatLunch(campbellsTomatoSoup).then(() => {
50+
stopTimer();
51+
say('Finished lunch');
52+
});
5753
}
5854

5955
main();

src/functions/5-functions-await.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,8 @@
33
const { startTimer, stopTimer } = require('./timer');
44

55
const campbellsTomatoSoup = {
6-
brand: 'Campbell\'s',
7-
contents: 'tomato soup'
6+
brand: "Campbell's",
7+
contents: 'tomato soup',
88
};
99

1010
function say(message) {
@@ -43,7 +43,7 @@ async function eatLunch(foodCan) {
4343
}
4444

4545
async function main() {
46-
say('It\'s lunch time!');
46+
say("It's lunch time!");
4747
startTimer(counter => say(counter));
4848
await eatLunch(campbellsTomatoSoup);
4949
stopTimer();

src/functions/6-app/SpeechSynthesizer.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ class SpeechSynthesizer {
1010

1111
initialize(render) {
1212
this.render = render;
13-
return new Promise((resolve) => {
13+
return new Promise(resolve => {
1414
speechSynthesis.onvoiceschanged = () => {
1515
this.voices = speechSynthesis.getVoices();
1616
console.table(this.voices);
@@ -20,7 +20,7 @@ class SpeechSynthesizer {
2020
}
2121

2222
speak(message) {
23-
return new Promise((resolve) => {
23+
return new Promise(resolve => {
2424
this.utterance = new SpeechSynthesisUtterance();
2525
this.utterance.text = message;
2626
this.utterance.voice = this.voices.find(voice => voice.name === this.name);

src/functions/6-app/app.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,8 @@
66
const synthesizer = new SpeechSynthesizer('Google UK English Male');
77

88
const campbellsTomatoSoup = {
9-
brand: 'Campbell\'s',
10-
contents: 'tomato soup'
9+
brand: "Campbell's",
10+
contents: 'tomato soup',
1111
};
1212

1313
function render(message) {
@@ -52,7 +52,7 @@
5252

5353
async function main() {
5454
await synthesizer.initialize(render);
55-
await say('It\'s lunch time!');
55+
await say("It's lunch time!");
5656
await eatLunch(campbellsTomatoSoup);
5757
await say('Finished lunch.');
5858
}

src/functions/timer.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,5 +21,5 @@ function stopTimer() {
2121

2222
module.exports = {
2323
startTimer,
24-
stopTimer
24+
stopTimer,
2525
};

src/lecture3/index.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,12 +4,12 @@
44
const QUERIES = [
55
{
66
description: 'All Dutch laureates',
7-
url: 'http://api.nobelprize.org/v1/laureate.json?bornCountryCode=NL'
7+
url: 'http://api.nobelprize.org/v1/laureate.json?bornCountryCode=NL',
88
},
99
{
1010
description: 'All female laureates',
11-
url: 'http://api.nobelprize.org/v1/laureate.json?gender=female'
12-
}
11+
url: 'http://api.nobelprize.org/v1/laureate.json?gender=female',
12+
},
1313
];
1414

1515
const app = new App(QUERIES);

0 commit comments

Comments
 (0)