Skip to content

Commit 7381b1d

Browse files
author
Gael Estrera
committed
Node
1 parent 92c82fa commit 7381b1d

File tree

10 files changed

+81
-1
lines changed

10 files changed

+81
-1
lines changed

DesignPatterns/Notes.txt

+11-1
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ https://www.udemy.com/course/learn-creational-design-patterns-in-java/learn/lect
77
https://www.youtube.com/watch?v=NU_1StN5Tkk (What im based on rn)
88
https://github.com/kamranahmedse/design-patterns-for-humans (VERY GOOD)
99

10+
1011
Creational - Ways to create objects
1112
Structural - Ways these objects are related
1213
Behavioral - Interaction/communication between these objects
@@ -21,4 +22,13 @@ interfaces
2122

2223
Encapsulation
2324
- bundling data (access modifiers), setting methods for those data (getter, setter)
24-
- for robust applications
25+
- for robust applications
26+
27+
28+
29+
MSYS 42 Insights
30+
31+
- When doing error validations, group variable validations into one group of condition (to avoid sparse code)
32+
- if a variable could be null, make an if condition with corresponding child conditions
33+
- Keep testing
34+
- Use algorithms that do not cause server-side lag or delays

Node/App.js

+5
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
const names = require('./names'); //to signifiy you will be using ur own modules within ur own directory
22
const f1 = require('./utils');
3+
const path = require('path');
4+
const { readFileSync, writeFileSync, write } = require('fs')
35

46
array = []
57
for (let i=0; i < names.names.length; i++){
@@ -8,3 +10,6 @@ for (let i=0; i < names.names.length; i++){
810
console.log(array);
911

1012

13+
const FilePath1 = path.join('/ChildFolder','Child1.js')
14+
const base1 = path.basename(FilePath1);
15+
const absolute = path.resolve(__dirname, 'ChildFolder','Child1.js')

Node/Async.js

+36
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
const names = require('./names'); //to signifiy you will be using ur own modules within ur own directory
2+
const f1 = require('./utils');
3+
const path = require('path');
4+
const { readFile, writeFile } = require('fs')
5+
6+
readFile('./TextTwo/WhoAmI.txt', 'utf8', (err,result)=>{
7+
if (err){
8+
console.log('There is an error!');
9+
return;
10+
}
11+
const newpath = path.join('/TextTwo','Crush.txt');
12+
const first = result;
13+
readFile('.' + newpath, 'utf-8',(err,result)=>{
14+
if (err){
15+
console.log('Error in 2nd iteration!');
16+
return;
17+
}
18+
const second = result;
19+
const childpath = path.join('/ChildFolder')
20+
writeFile(
21+
"." + childpath + "/" + "verdict.txt",
22+
`Who is this person? : ${first} + " " + ${second}`,
23+
(err, result) => {
24+
if (err){
25+
console.log(err);
26+
return;
27+
}
28+
console.log('Processes finished!');
29+
}
30+
)
31+
})
32+
33+
})
34+
35+
const seek = path.join('/TextTwo','/WhoAmI.txt');
36+

Node/ChildFolder/Child1.js

Whitespace-only changes.

Node/ChildFolder/verdict.txt

+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
Who is this person? : Hi, my name is Gael! I am an aspiring developer!, I'm very proficient with software development through experience!This is just an addition! + " " + I wish a girl will like me for who I am..

Node/Sync.js

+24
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
const names = require('./names'); //to signifiy you will be using ur own modules within ur own directory
2+
const f1 = require('./utils');
3+
const path = require('path');
4+
const { readFileSync, writeFileSync, write } = require('fs')
5+
6+
//Synchronous File read/write
7+
const intro = readFileSync('./TextOne/About.txt','utf-8');
8+
const skills = readFileSync('./TextOne/Skills.txt','utf-8');
9+
const seek = path.join('/TextTwo','WhoAmI.txt')
10+
11+
writeFileSync(
12+
'./TextTwo/WhoAmI.txt',
13+
`${intro}, ${skills}`
14+
)
15+
16+
writeFileSync(
17+
'.' + seek,
18+
'This is just an addition!',
19+
{flag: 'a'}
20+
)
21+
22+
//console.log(readFileSync('./TextTwo/WhoAmI.txt','utf8'));
23+
24+

Node/TextOne/About.txt

+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
Hi, my name is Gael! I am an aspiring developer!

Node/TextOne/Skills.txt

+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
I'm very proficient with software development through experience!

Node/TextTwo/Crush.txt

+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
I wish a girl will like me for who I am..

Node/TextTwo/WhoAmI.txt

+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
Hi, my name is Gael! I am an aspiring developer!, I'm very proficient with software development through experience!This is just an addition!

0 commit comments

Comments
 (0)