Skip to content

Commit a76480d

Browse files
author
Miqueas
committed
Minor changes in the TS example
1 parent 955f146 commit a76480d

File tree

1 file changed

+16
-23
lines changed

1 file changed

+16
-23
lines changed

Github.ts

Lines changed: 16 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -1,31 +1,24 @@
11
import yargs from "https://deno.land/x/[email protected]/deno.ts";
22

3+
// Yeah I'm lazy af
34
const print = console.log;
45
const BASE_URL = "https://api.github.com/users/";
56

6-
class GthUserItem {
7+
type GthUserItem = {
78
count: number;
89
arr: string[];
9-
10-
constructor(n: number) {
11-
this.count = n;
12-
this.arr = [];
13-
}
14-
}
10+
};
1511

1612
class GthUser {
17-
username: string;
18-
name?: string;
19-
bio?: string;
20-
link?: string;
21-
repos?: GthUserItem;
22-
gists?: GthUserItem;
23-
followers?: GthUserItem;
24-
following?: GthUserItem;
25-
26-
constructor(username: string) {
27-
this.username = username;
28-
}
13+
name: string = "";
14+
bio: string = "";
15+
link: string = "";
16+
repos: GthUserItem = { count: 0, arr: [] };
17+
gists: GthUserItem = { count: 0, arr: [] };
18+
followers: GthUserItem = { count: 0, arr: [] };
19+
following: GthUserItem = { count: 0, arr: [] };
20+
21+
constructor(public username: string) {}
2922

3023
static async create(user: string): Promise<GthUser> {
3124
let self = new GthUser(user);
@@ -41,10 +34,10 @@ class GthUser {
4134
self.bio = obj.bio;
4235
self.link = obj.html_url;
4336

44-
self.repos = new GthUserItem(obj.public_repos);
45-
self.gists = new GthUserItem(obj.public_gists);
46-
self.followers = new GthUserItem(obj.followers);
47-
self.following = new GthUserItem(obj.following);
37+
self.repos.count = obj.public_repos;
38+
self.gists.count = obj.public_gists;
39+
self.followers.count = obj.followers;
40+
self.following.count = obj.following;
4841

4942
return self;
5043
}

0 commit comments

Comments
 (0)