Skip to content

Commit 6d49f11

Browse files
committed
Ejemplos sobre clases
1 parent e929fe4 commit 6d49f11

18 files changed

+740
-0
lines changed

2023-03-14/clases/.gitignore

Lines changed: 169 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,169 @@
1+
# Based on https://raw.githubusercontent.com/github/gitignore/main/Node.gitignore
2+
3+
# Logs
4+
5+
logs
6+
_.log
7+
npm-debug.log_
8+
yarn-debug.log*
9+
yarn-error.log*
10+
lerna-debug.log*
11+
.pnpm-debug.log*
12+
13+
# Diagnostic reports (https://nodejs.org/api/report.html)
14+
15+
report.[0-9]_.[0-9]_.[0-9]_.[0-9]_.json
16+
17+
# Runtime data
18+
19+
pids
20+
_.pid
21+
_.seed
22+
\*.pid.lock
23+
24+
# Directory for instrumented libs generated by jscoverage/JSCover
25+
26+
lib-cov
27+
28+
# Coverage directory used by tools like istanbul
29+
30+
coverage
31+
\*.lcov
32+
33+
# nyc test coverage
34+
35+
.nyc_output
36+
37+
# Grunt intermediate storage (https://gruntjs.com/creating-plugins#storing-task-files)
38+
39+
.grunt
40+
41+
# Bower dependency directory (https://bower.io/)
42+
43+
bower_components
44+
45+
# node-waf configuration
46+
47+
.lock-wscript
48+
49+
# Compiled binary addons (https://nodejs.org/api/addons.html)
50+
51+
build/Release
52+
53+
# Dependency directories
54+
55+
node_modules/
56+
jspm_packages/
57+
58+
# Snowpack dependency directory (https://snowpack.dev/)
59+
60+
web_modules/
61+
62+
# TypeScript cache
63+
64+
\*.tsbuildinfo
65+
66+
# Optional npm cache directory
67+
68+
.npm
69+
70+
# Optional eslint cache
71+
72+
.eslintcache
73+
74+
# Optional stylelint cache
75+
76+
.stylelintcache
77+
78+
# Microbundle cache
79+
80+
.rpt2_cache/
81+
.rts2_cache_cjs/
82+
.rts2_cache_es/
83+
.rts2_cache_umd/
84+
85+
# Optional REPL history
86+
87+
.node_repl_history
88+
89+
# Output of 'npm pack'
90+
91+
\*.tgz
92+
93+
# Yarn Integrity file
94+
95+
.yarn-integrity
96+
97+
# dotenv environment variable files
98+
99+
.env
100+
.env.development.local
101+
.env.test.local
102+
.env.production.local
103+
.env.local
104+
105+
# parcel-bundler cache (https://parceljs.org/)
106+
107+
.cache
108+
.parcel-cache
109+
110+
# Next.js build output
111+
112+
.next
113+
out
114+
115+
# Nuxt.js build / generate output
116+
117+
.nuxt
118+
dist
119+
120+
# Gatsby files
121+
122+
.cache/
123+
124+
# Comment in the public line in if your project uses Gatsby and not Next.js
125+
126+
# https://nextjs.org/blog/next-9-1#public-directory-support
127+
128+
# public
129+
130+
# vuepress build output
131+
132+
.vuepress/dist
133+
134+
# vuepress v2.x temp and cache directory
135+
136+
.temp
137+
.cache
138+
139+
# Docusaurus cache and generated files
140+
141+
.docusaurus
142+
143+
# Serverless directories
144+
145+
.serverless/
146+
147+
# FuseBox cache
148+
149+
.fusebox/
150+
151+
# DynamoDB Local files
152+
153+
.dynamodb/
154+
155+
# TernJS port file
156+
157+
.tern-port
158+
159+
# Stores VSCode versions used for testing VSCode extensions
160+
161+
.vscode-test
162+
163+
# yarn v2
164+
165+
.yarn/cache
166+
.yarn/unplugged
167+
.yarn/build-state.yml
168+
.yarn/install-state.gz
169+
.pnp.\*

2023-03-14/clases/bun.lockb

1.11 KB
Binary file not shown.

2023-03-14/clases/clases.ts

Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
2+
class Animal {
3+
weight: number;
4+
5+
constructor(weight: number = 0.0) {
6+
this.weight = weight;
7+
}
8+
9+
gruñe() {
10+
console.log("Grrr");
11+
}
12+
}
13+
14+
class Person extends Animal {
15+
name: string;
16+
age: number;
17+
durmiendo: boolean = false;
18+
19+
constructor(name: string, age: number, weight: number) {
20+
super(weight); // constructor de Animal
21+
this.name = name;
22+
this.age = age;
23+
}
24+
25+
quéTal() {
26+
console.log(`Hola, mi nombre es ${this.name}, qué tal!`);
27+
}
28+
29+
duérmete() {
30+
this.durmiendo = true;
31+
}
32+
}
33+
34+
class Point2D {
35+
x: number = 0;
36+
y: number = 0;
37+
}
38+
39+
let pt = new Point2D();
40+
console.log(pt);
41+
42+
let p = new Person("James Bond", 27, 0.0);
43+
p.quéTal();
44+
p.gruñe();
45+
console.log(p);

2023-03-14/clases/package.json

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
{
2+
"name": "clases",
3+
"module": "clases.ts",
4+
"type": "module",
5+
"devDependencies": {
6+
"bun-types": "^0.5.0"
7+
}
8+
}

2023-03-14/clases/tsconfig.json

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
{
2+
"compilerOptions": {
3+
"lib": [
4+
"ESNext"
5+
],
6+
"module": "esnext",
7+
"target": "esnext",
8+
"moduleResolution": "nodenext",
9+
"strict": true,
10+
"downlevelIteration": true,
11+
"skipLibCheck": true,
12+
"jsx": "preserve",
13+
"allowSyntheticDefaultImports": true,
14+
"forceConsistentCasingInFileNames": true,
15+
"allowJs": true,
16+
"types": [
17+
"bun-types" // add Bun global
18+
]
19+
}
20+
}

2023-03-14/excepciones.js

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
2+
obj = {
3+
a: 1,
4+
};
5+
6+
obj.metodo();

0 commit comments

Comments
 (0)