Skip to content

Commit 3c7c957

Browse files
committed
updates
1 parent aecec4a commit 3c7c957

File tree

98 files changed

+1982
-658
lines changed

Some content is hidden

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

98 files changed

+1982
-658
lines changed

.eslintignore

+2
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
node_modules
2+
dist

.eslintrc.json

+22
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
{
2+
"env": {
3+
"browser": true,
4+
"es2021": true
5+
},
6+
"extends": [
7+
"eslint:recommended",
8+
"plugin:@typescript-eslint/recommended"
9+
],
10+
"parser": "@typescript-eslint/parser",
11+
"parserOptions": {
12+
"ecmaVersion": 12,
13+
"sourceType": "module"
14+
},
15+
"plugins": [
16+
"@typescript-eslint"
17+
],
18+
"rules": {
19+
"multiline-comment-style": 2,
20+
"spaced-comment": 2
21+
}
22+
}

.prettierrc

+19
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
{
2+
"arrowParens": "always",
3+
"bracketSpacing": false,
4+
"embeddedLanguageFormatting": "auto",
5+
"htmlWhitespaceSensitivity": "css",
6+
"insertPragma": false,
7+
"jsxBracketSameLine": false,
8+
"jsxSingleQuote": false,
9+
"printWidth": 90,
10+
"proseWrap": "preserve",
11+
"quoteProps": "as-needed",
12+
"requirePragma": false,
13+
"semi": false,
14+
"singleQuote": true,
15+
"tabWidth": 4,
16+
"trailingComma": "es5",
17+
"useTabs": false,
18+
"vueIndentScriptAndStyle": false
19+
}

dist/abstract-factory/big-chair.js

+4-4
Original file line numberDiff line numberDiff line change
@@ -2,16 +2,16 @@
22
Object.defineProperty(exports, "__esModule", { value: true });
33
class BigChair {
44
constructor() {
5-
this.name = "BigChair";
5+
this.name = 'BigChair';
66
this.height = 80;
77
this.width = 80;
88
this.depth = 80;
99
}
1010
getDimensions() {
1111
return {
12-
"width": this.width,
13-
"depth": this.depth,
14-
"height": this.height
12+
width: this.width,
13+
depth: this.depth,
14+
height: this.height,
1515
};
1616
}
1717
}

dist/abstract-factory/big-table.js

+4-4
Original file line numberDiff line numberDiff line change
@@ -2,16 +2,16 @@
22
Object.defineProperty(exports, "__esModule", { value: true });
33
class BigTable {
44
constructor() {
5-
this.name = "BigTable";
5+
this.name = 'BigTable';
66
this.height = 80;
77
this.width = 80;
88
this.depth = 80;
99
}
1010
getDimensions() {
1111
return {
12-
"width": this.width,
13-
"depth": this.depth,
14-
"height": this.height
12+
width: this.width,
13+
depth: this.depth,
14+
height: this.height,
1515
};
1616
}
1717
}

dist/abstract-factory/client.js

+2-2
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,9 @@
22
Object.defineProperty(exports, "__esModule", { value: true });
33
// Abstract Factory Use Case Example Code
44
const furniture_factory_1 = require("./furniture-factory");
5-
let FURNITURE = furniture_factory_1.default.getFurniture("SmallChair");
5+
let FURNITURE = furniture_factory_1.default.getFurniture('SmallChair');
66
console.log(FURNITURE === null || FURNITURE === void 0 ? void 0 : FURNITURE.name);
77
console.log(FURNITURE === null || FURNITURE === void 0 ? void 0 : FURNITURE.getDimensions());
8-
FURNITURE = furniture_factory_1.default.getFurniture("MediumTable");
8+
FURNITURE = furniture_factory_1.default.getFurniture('MediumTable');
99
console.log(FURNITURE === null || FURNITURE === void 0 ? void 0 : FURNITURE.name);
1010
console.log(FURNITURE === null || FURNITURE === void 0 ? void 0 : FURNITURE.getDimensions());

dist/abstract-factory/factory-a.js

+3-3
Original file line numberDiff line numberDiff line change
@@ -6,23 +6,23 @@ var FactoryA;
66
(function (FactoryA) {
77
class ConcreteProductA {
88
constructor() {
9-
this.name = "FactoryA:ConcreteProductA";
9+
this.name = 'FactoryA:ConcreteProductA';
1010
}
1111
createObject() {
1212
return this;
1313
}
1414
}
1515
class ConcreteProductB {
1616
constructor() {
17-
this.name = "FactoryA:ConcreteProductB";
17+
this.name = 'FactoryA:ConcreteProductB';
1818
}
1919
createObject() {
2020
return this;
2121
}
2222
}
2323
class ConcreteProductC {
2424
constructor() {
25-
this.name = "FactoryA:ConcreteProductC";
25+
this.name = 'FactoryA:ConcreteProductC';
2626
}
2727
createObject() {
2828
return this;

dist/abstract-factory/factory-b.js

+3-3
Original file line numberDiff line numberDiff line change
@@ -6,23 +6,23 @@ var FactoryB;
66
(function (FactoryB) {
77
class ConcreteProductA {
88
constructor() {
9-
this.name = "FactoryB:ConcreteProductA";
9+
this.name = 'FactoryB:ConcreteProductA';
1010
}
1111
createObject() {
1212
return this;
1313
}
1414
}
1515
class ConcreteProductB {
1616
constructor() {
17-
this.name = "FactoryB:ConcreteProductB";
17+
this.name = 'FactoryB:ConcreteProductB';
1818
}
1919
createObject() {
2020
return this;
2121
}
2222
}
2323
class ConcreteProductC {
2424
constructor() {
25-
this.name = "FactoryB:ConcreteProductC";
25+
this.name = 'FactoryB:ConcreteProductC';
2626
}
2727
createObject() {
2828
return this;

dist/abstract-factory/furniture-factory.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
"use strict";
2-
"Abstract Furniture Factory";
2+
'Abstract Furniture Factory';
33
Object.defineProperty(exports, "__esModule", { value: true });
44
const chair_factory_1 = require("./chair-factory");
55
const table_factory_1 = require("./table-factory");

dist/builder/builder-concept.js

+2-6
Original file line numberDiff line numberDiff line change
@@ -30,12 +30,8 @@ var BuilderConcept;
3030
class Director {
3131
// The Director, building a complex representation
3232
static construct() {
33-
"Constructs and returns the final product";
34-
return new Builder()
35-
.buildPartA()
36-
.buildPartB()
37-
.buildPartC()
38-
.getResult();
33+
'Constructs and returns the final product';
34+
return new Builder().buildPartA().buildPartB().buildPartC().getResult();
3935
}
4036
}
4137
// The Client

dist/composite/client.js

+10-10
Original file line numberDiff line numberDiff line change
@@ -1,23 +1,23 @@
11
"use strict";
2-
"A use case of the composite pattern.";
2+
'A use case of the composite pattern.';
33
Object.defineProperty(exports, "__esModule", { value: true });
44
const file_1 = require("./file");
55
const folder_1 = require("./folder");
6-
const FILESYSTEM = new folder_1.Folder("root");
7-
const FILE_1 = new file_1.File("abc.txt");
8-
const FILE_2 = new file_1.File("123.txt");
6+
const FILESYSTEM = new folder_1.Folder('root');
7+
const FILE_1 = new file_1.File('abc.txt');
8+
const FILE_2 = new file_1.File('123.txt');
99
FILESYSTEM.attach(FILE_1);
1010
FILESYSTEM.attach(FILE_2);
11-
const FOLDER_A = new folder_1.Folder("folder_a");
11+
const FOLDER_A = new folder_1.Folder('folder_a');
1212
FILESYSTEM.attach(FOLDER_A);
13-
const FILE_3 = new file_1.File("xyz.txt");
13+
const FILE_3 = new file_1.File('xyz.txt');
1414
FOLDER_A.attach(FILE_3);
15-
const FOLDER_B = new folder_1.Folder("folder_b");
16-
const FILE_4 = new file_1.File("456.txt");
15+
const FOLDER_B = new folder_1.Folder('folder_b');
16+
const FILE_4 = new file_1.File('456.txt');
1717
FOLDER_B.attach(FILE_4);
1818
FILESYSTEM.attach(FOLDER_B);
19-
FILESYSTEM.dir("");
19+
FILESYSTEM.dir('');
2020
// now move FOLDER_A and its contents to FOLDER_B
2121
console.log();
2222
FOLDER_B.attach(FOLDER_A);
23-
FILESYSTEM.dir("");
23+
FILESYSTEM.dir('');

dist/composite/composite-concept.js

+13-7
Original file line numberDiff line numberDiff line change
@@ -9,12 +9,15 @@ var CompositeConcept;
99
this.name = name;
1010
}
1111
method() {
12-
const parent = this.referenceToParent ? this.referenceToParent.name : "none";
12+
const parent = this.referenceToParent
13+
? this.referenceToParent.name
14+
: 'none';
1315
console.log(`<Leaf>\t\tname:${this.name}\tParent:\t${parent}`);
1416
}
1517
detach() {
16-
"Detaching this leaf from its parent composite";
18+
'Detaching this leaf from its parent composite';
1719
if (this.referenceToParent) {
20+
;
1821
this.referenceToParent.delete(this);
1922
}
2023
}
@@ -25,17 +28,19 @@ var CompositeConcept;
2528
this.components = [];
2629
}
2730
method() {
28-
const parent = this.referenceToParent ? this.referenceToParent.name : "none";
31+
const parent = this.referenceToParent
32+
? this.referenceToParent.name
33+
: 'none';
2934
console.log(`<Composite>\tname:${this.name}\tParent:\t${parent}\tComponents:${this.components.length}`);
30-
this.components.forEach(component => {
35+
this.components.forEach((component) => {
3136
component.method();
3237
});
3338
}
3439
attach(component) {
3540
/*
36-
* Detach leaf / composite from any current parent reference and
37-
* then set the parent reference to this composite(self)
38-
*/
41+
* Detach leaf / composite from any current parent reference and
42+
* then set the parent reference to this composite(self)
43+
*/
3944
component.detach();
4045
component.referenceToParent = this;
4146
this.components.push(component);
@@ -50,6 +55,7 @@ var CompositeConcept;
5055
detach() {
5156
// Detaching this composite from its parent composite
5257
if (this.referenceToParent) {
58+
;
5359
this.referenceToParent.delete(this);
5460
this.referenceToParent = undefined;
5561
}

dist/composite/file.js

+2-1
Original file line numberDiff line numberDiff line change
@@ -10,8 +10,9 @@ class File {
1010
console.log(`${indent}<FILE> ${this.name}`);
1111
}
1212
detach() {
13-
"Detaching this leaf from its parent composite";
13+
'Detaching this leaf from its parent composite';
1414
if (this.referenceToParent) {
15+
;
1516
this.referenceToParent.delete(this);
1617
}
1718
}

dist/composite/folder.js

+6-5
Original file line numberDiff line numberDiff line change
@@ -9,15 +9,15 @@ class Folder {
99
dir(indent) {
1010
const parent_id = this.referenceToParent;
1111
console.log(`${indent}<DIR> ${this.name}`);
12-
this.components.forEach(component => {
13-
component.dir(indent + "..");
12+
this.components.forEach((component) => {
13+
component.dir(indent + '..');
1414
});
1515
}
1616
attach(component) {
1717
/*
18-
* Detach leaf / composite from any current parent reference and
19-
* then set the parent reference to this composite(self)
20-
*/
18+
* Detach leaf / composite from any current parent reference and
19+
* then set the parent reference to this composite(self)
20+
*/
2121
component.detach();
2222
component.referenceToParent = this;
2323
this.components.push(component);
@@ -32,6 +32,7 @@ class Folder {
3232
detach() {
3333
// Detaching this composite from its parent composite
3434
if (this.referenceToParent) {
35+
;
3536
this.referenceToParent.delete(this);
3637
this.referenceToParent = undefined;
3738
}

dist/composite/interface-component.js

-2
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,2 @@
11
"use strict";
2-
//namespace CompositeUseCase {
32
Object.defineProperty(exports, "__esModule", { value: true });
4-
//}

dist/decorator/add.js

+6-2
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,12 @@
22
Object.defineProperty(exports, "__esModule", { value: true });
33
class _Add {
44
constructor(val1, val2) {
5-
const left = val1.hasOwnProperty('value') ? val1.value : val1;
6-
const right = val2.hasOwnProperty('value') ? val2.value : val2;
5+
const left = val1.hasOwnProperty('value')
6+
? val1.value
7+
: val1;
8+
const right = val2.hasOwnProperty('value')
9+
? val2.value
10+
: val2;
711
this.value = left + right;
812
}
913
}

dist/decorator/decorator-concept.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ var DecoratorConcept;
44
(function (DecoratorConcept) {
55
class Component {
66
method() {
7-
return "Component Method";
7+
return 'Component Method';
88
}
99
}
1010
class Decorator {

dist/decorator/sub.js

+6-2
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,12 @@
22
Object.defineProperty(exports, "__esModule", { value: true });
33
class _Sub {
44
constructor(val1, val2) {
5-
const left = val1.hasOwnProperty('value') ? val1.value : val1;
6-
const right = val2.hasOwnProperty('value') ? val2.value : val2;
5+
const left = val1.hasOwnProperty('value')
6+
? val1.value
7+
: val1;
8+
const right = val2.hasOwnProperty('value')
9+
? val2.value
10+
: val2;
711
this.value = left - right;
812
}
913
}

dist/facade/facade-concept.js

+5-5
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
class SubSystemClassA {
44
// A hypothetically complicated class
55
method() {
6-
return "A";
6+
return 'A';
77
}
88
}
99
class SubSystemClassB {
@@ -36,10 +36,10 @@ class Facade {
3636
// The Client
3737
// Calling potentially complicated subsystems directly
3838
console.log(new SubSystemClassA().method());
39-
console.log(new SubSystemClassB().method("B"));
40-
console.log(new SubSystemClassC().method({ "C": [1, 2, 3] }));
39+
console.log(new SubSystemClassB().method('B'));
40+
console.log(new SubSystemClassC().method({ C: [1, 2, 3] }));
4141
// or using the simplified facade instead
4242
const FACADE = new Facade();
4343
console.log(FACADE.subSystemClassA());
44-
console.log(FACADE.subSystemClassB("B"));
45-
console.log(FACADE.subSystemClassC({ "C": [1, 2, 3] }));
44+
console.log(FACADE.subSystemClassB('B'));
45+
console.log(FACADE.subSystemClassC({ C: [1, 2, 3] }));

dist/factory/big-chair.js

+3-8
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,12 @@
11
"use strict";
22
Object.defineProperty(exports, "__esModule", { value: true });
3-
class BigChair {
3+
const chair_1 = require("./chair");
4+
class BigChair extends chair_1.default {
45
constructor() {
6+
super();
57
this.height = 80;
68
this.width = 80;
79
this.depth = 80;
810
}
9-
getDimensions() {
10-
return {
11-
"width": this.width,
12-
"depth": this.depth,
13-
"height": this.height
14-
};
15-
}
1611
}
1712
exports.default = BigChair;

0 commit comments

Comments
 (0)