Skip to content

Commit 9b63c2f

Browse files
committed
PR comments:
- use new hpw; - remove setting names for anonymous functions for old hpw; - remove unnecessary parentheses; - refactor constructing current date string.
1 parent a532d57 commit 9b63c2f

8 files changed

+11
-39
lines changed

Exercises/1-closure.js

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

33
const coffee = (volume, strength) =>
4-
(`Coffee volume: ${volume}ml, strength: ${strength}`);
4+
`Coffee volume: ${volume}ml, strength: ${strength}`;
55

66
const defineCoffeeType = volume => strength => coffee(volume, strength);
77

@@ -12,14 +12,4 @@ const defineCoffeeType = volume => strength => coffee(volume, strength);
1212
const espresso = null;
1313
const americano = null;
1414

15-
// Set names for anonymous functions (for tests).
16-
if (typeof espresso === 'function') {
17-
Object.defineProperty(espresso, 'name',
18-
{ value: 'espresso', configurable: true });
19-
}
20-
if (typeof americano === 'function') {
21-
Object.defineProperty(americano, 'name',
22-
{ value: 'americano', configurable: true });
23-
}
24-
2515
module.exports = { espresso, americano };

Exercises/1-closure.test

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
([{
1+
[{
22
name: 'espresso',
33
length: [30, 70],
44
cases: [
@@ -13,4 +13,4 @@
1313
['medium', 'Coffee volume: 150ml, strength: medium'],
1414
['strong', 'Coffee volume: 150ml, strength: strong'],
1515
]
16-
}])
16+
}]

Exercises/2-lambda.test

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -3,11 +3,8 @@
33
length: [150, 400],
44
test: tagDate => {
55
{
6-
const today = new Date();
7-
const dd = String(today.getDate()).padStart(2, '0');
8-
const mm = String(today.getMonth() + 1).padStart(2, '0');
9-
const yyyy = today.getFullYear();
10-
const expected = `[${yyyy}-${mm}-${dd}] Test`;
6+
const date = new Date().toISOString().substring(0, 10);
7+
const expected = `[${date}] Test`;
118
const y = tagDate('Test');
129
if (y !== expected) {
1310
throw new Error(`tagDate('Test') === ${y} expected: ${expected}`);

Exercises/3-bind.js

Lines changed: 0 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -22,14 +22,4 @@ const H = (exp, ...args) => {
2222
const average = null;
2323
const rootMeanSquare = null;
2424

25-
// Set names for anonymous functions (for tests).
26-
if (typeof average === 'function') {
27-
Object.defineProperty(average, 'name',
28-
{ value: 'average', configurable: true });
29-
}
30-
if (typeof rootMeanSquare === 'function') {
31-
Object.defineProperty(rootMeanSquare, 'name',
32-
{ value: 'rootMeanSquare', configurable: true });
33-
}
34-
3525
module.exports = { average, rootMeanSquare };

Exercises/4-curry.js

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
// Check 4 digit pin.
44
const checkPin = (...code) =>
5-
(code.join('') === '4967');
5+
code.join('') === '4967';
66

77
// Define function curry that accepts the length of the function
88
// (amount of function arguments) and the function.
@@ -13,9 +13,4 @@ const curry = (length, fn) => (...args) => null;
1313
// Usage: press('3')('4')('5')('6')
1414
const press = curry(4, checkPin);
1515

16-
// Set name for anonymous function (for tests).
17-
if (typeof press === 'function') {
18-
Object.defineProperty(press, 'name', { value: 'press', configurable: true });
19-
}
20-
2116
module.exports = { press };

Exercises/5-chaining.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
// Check 4 digit pin.
44
const checkPin = (ch1, ch2, ch3, ch4) =>
5-
([ch1, ch2, ch3, ch4].join('') === '4967');
5+
[ch1, ch2, ch3, ch4].join('') === '4967';
66

77
// Impement function press
88
// that allows to enter pin code by one character,

package-lock.json

Lines changed: 3 additions & 3 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,6 @@
99
},
1010
"dependencies": {
1111
"eslint": "^6.6.0",
12-
"hpw": "^0.1.9"
12+
"hpw": "^0.1.11"
1313
}
1414
}

0 commit comments

Comments
 (0)