Skip to content

Commit 4686ce4

Browse files
committed
Move code to ES2015
- Compound/1 - Compound/2 - Compound/3 - Compound/4 - Decorator - Facade - Factory/1 - Factory/2 - Iterator/1 - Iterator/2
1 parent 4b9ed04 commit 4686ce4

File tree

376 files changed

+6961
-4973
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

376 files changed

+6961
-4973
lines changed

Adapter/index.html

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
<html>
22
<head>
3-
<link type="text/css" rel="stylesheet" href="../css/style.css"/>
3+
<link type="text/css" rel="stylesheet" href="../statics/css/style.css"/>
44
<title>Adapter Pattern</title>
55
</head>
66
<body>
@@ -32,7 +32,7 @@ <h1>ADAPTER</h1>
3232
</div>
3333

3434

35-
<script type="text/javascript" src="../js/utils.js"></script>
35+
<script type="text/javascript" src="../statics/js/utils.js"></script>
3636
<script type="text/javascript" src="dist/scripts/main.js"></script>
3737
</body>
3838
</html>

Adapter/scripts/Duck.js

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,13 @@
11
class Duck {
22
constructor() {}
33

4-
fly() {
5-
throw new Error('This method must be overwritten!');
6-
}
7-
quack() {
8-
throw new Error('This method must be overwritten!');
9-
}
4+
fly() {
5+
throw new Error('This method must be overwritten!');
6+
}
7+
8+
quack() {
9+
throw new Error('This method must be overwritten!');
10+
}
1011
}
1112

12-
export default Duck;
13+
export default Duck;

Adapter/scripts/MallardDuck.js

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,13 @@
11
import Duck from './Duck';
22

33
class MallardDuck extends Duck {
4-
fly() {
5-
console.log('Can fly long distances!');
6-
}
7-
quack() {
8-
console.log('Quack! Quack!');
9-
}
4+
fly() {
5+
console.log('Can fly long distances!');
6+
}
7+
8+
quack() {
9+
console.log('Quack! Quack!');
10+
}
1011
}
1112

12-
export default MallardDuck;
13+
export default MallardDuck;

Adapter/scripts/Turkey.js

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,11 @@
11
class Turkey {
2-
fly() {
3-
throw new Error('This method must be overwritten!');
4-
}
5-
gobble() {
6-
throw new Error('This method must be overwritten');
7-
}
2+
fly() {
3+
throw new Error('This method must be overwritten!');
4+
}
5+
6+
gobble() {
7+
throw new Error('This method must be overwritten');
8+
}
89
}
910

10-
export default Turkey;
11+
export default Turkey;

Adapter/scripts/TurkeyAdapter.js

Lines changed: 15 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,20 @@
11
import Duck from './Duck';
22

3-
class TurkeyAdapter extends Duck{
4-
constructor(oTurkey) {
5-
super(oTurkey);
6-
this.oTurkey = oTurkey;
7-
}
8-
fly() {
9-
for(let index = 0, maxFly = 5; index < maxFly; index++) {
10-
this.oTurkey.fly();
11-
}
12-
}
3+
class TurkeyAdapter extends Duck {
4+
constructor(oTurkey) {
5+
super(oTurkey);
6+
this.oTurkey = oTurkey;
7+
}
138

14-
quack() {
15-
this.oTurkey.gobble();
16-
}
9+
fly() {
10+
for (let index = 0, maxFly = 5; index < maxFly; index++) {
11+
this.oTurkey.fly();
12+
}
13+
}
14+
15+
quack() {
16+
this.oTurkey.gobble();
17+
}
1718
}
1819

19-
export default TurkeyAdapter;
20+
export default TurkeyAdapter;

Adapter/scripts/WildTurkey.js

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,13 @@
11
import Turkey from './Turkey';
22

33
class WildTurkey extends Turkey {
4-
fly() {
5-
console.log('Fly short distance!');
6-
}
7-
gobble() {
8-
console.log('Gobble!, Gobble!');
9-
}
4+
fly() {
5+
console.log('Fly short distance!');
6+
}
7+
8+
gobble() {
9+
console.log('Gobble!, Gobble!');
10+
}
1011
}
1112

12-
export default WildTurkey;
13+
export default WildTurkey;

Chaining/index.html

Lines changed: 17 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1,23 +1,23 @@
11
<html>
2-
<head>
3-
<link type="text/css" rel="stylesheet" href="../css/style.css"/>
4-
<title>Chain Pattern</title>
5-
</head>
6-
<body>
7-
<div id="source">
8-
<h2>Source</h2>
2+
<head>
3+
<link type="text/css" rel="stylesheet" href="../statics/css/style.css"/>
4+
<title>Chain Pattern</title>
5+
</head>
6+
<body>
7+
<div id="source">
8+
<h2>Source</h2>
99
<pre>
1010
var oChainable = new Chainable();
1111
// This must return "21"
1212
oChainable.add(3).add(4).multiply(3).toString();
1313
</pre>
14-
</div>
15-
<div id="console">
16-
<h2>Console</h2>
17-
<ul></ul>
18-
<h1>Chain</h1>
19-
</div>
20-
<script type="text/javascript" src="../js/utils.js"></script>
21-
<script type="text/javascript" src="dist/scripts/main.js"></script>
22-
</body>
23-
</html>
14+
</div>
15+
<div id="console">
16+
<h2>Console</h2>
17+
<ul></ul>
18+
<h1>Chain</h1>
19+
</div>
20+
<script type="text/javascript" src="../statics/js/utils.js"></script>
21+
<script type="text/javascript" src="dist/scripts/main.js"></script>
22+
</body>
23+
</html>

Chaining/scripts/Chainable.js

Lines changed: 15 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,21 +1,21 @@
11
class Chainable {
2-
constructor() {
3-
this.number = 0;
4-
}
2+
constructor() {
3+
this.number = 0;
4+
}
55

6-
add(number) {
7-
this.number += number;
8-
return this;
9-
}
6+
add(number) {
7+
this.number += number;
8+
return this;
9+
}
1010

11-
multiply(number) {
12-
this.number *= number;
13-
return this;
14-
}
11+
multiply(number) {
12+
this.number *= number;
13+
return this;
14+
}
1515

16-
toString() {
17-
return this.number.toString();
18-
}
16+
toString() {
17+
return this.number.toString();
18+
}
1919
}
2020

21-
export default Chainable;
21+
export default Chainable;

Command/1/index.html

Lines changed: 15 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
11
<html>
2-
<head>
3-
<link type="text/css" rel="stylesheet" href="../../css/style.css"/>
2+
<head>
3+
<link type="text/css" rel="stylesheet" href="../../statics/css/style.css"/>
44
<title>Command Pattern</title>
5-
</head>
6-
<body>
7-
<div id="source">
8-
<h2>Source</h2>
5+
</head>
6+
<body>
7+
<div id="source">
8+
<h2>Source</h2>
99
<pre>
1010
import Light from './Light';
1111
import LightOnCommand from './LightOnCommand';
@@ -18,13 +18,13 @@ <h2>Source</h2>
1818
oSimpleRemote.setCommand(oLightCommand);
1919
oSimpleRemote.buttonWasPressed();
2020
</pre>
21-
</div>
22-
<div id="console">
23-
<h2>Console</h2>
24-
<ul></ul>
25-
<h1>COMMAND</h1>
26-
</div>
27-
<script type="text/javascript" src="../../js/utils.js"></script>
28-
<script type="text/javascript" src="dist/scripts/main.js"></script>
29-
</body>
21+
</div>
22+
<div id="console">
23+
<h2>Console</h2>
24+
<ul></ul>
25+
<h1>COMMAND</h1>
26+
</div>
27+
<script type="text/javascript" src="../../statics/js/utils.js"></script>
28+
<script type="text/javascript" src="dist/scripts/main.js"></script>
29+
</body>
3030
</html>

Command/1/scripts/Light.js

Lines changed: 0 additions & 16 deletions
This file was deleted.

0 commit comments

Comments
 (0)