Skip to content
This repository was archived by the owner on Nov 13, 2024. It is now read-only.

Commit 45a41df

Browse files
fix linting, formatting, and tests
1 parent 4f5f06f commit 45a41df

File tree

6 files changed

+44
-41
lines changed

6 files changed

+44
-41
lines changed

src/api/client.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -36,11 +36,11 @@ export class client {
3636
this.socket = socket;
3737
this.uploads = uploads;
3838

39-
socket.on("auth", (data) => {
39+
socket.on('auth', (data) => {
4040
for (const chat of data.chats) {
4141
api._chat_cache.set(chat._id, chat);
4242
}
43-
})
43+
});
4444
}
4545

4646
/** signup for an account and login */

src/api/rest.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -36,11 +36,11 @@ export class rest_api {
3636
/** the api token */
3737
api_token: string;
3838
/** @internal chat cache */
39-
_chat_cache = new Map<string, api_chat>();
39+
_chat_cache: Map<string, api_chat> = new Map();
4040
/** @internal post cache */
41-
_post_cache = new Map<string, api_post>();
41+
_post_cache: Map<string, api_post> = new Map();
4242
/** @internal user cache */
43-
_user_cache = new Map<string, api_user>();
43+
_user_cache: Map<string, api_user> = new Map();
4444

4545
constructor(opts: api_construction_opts) {
4646
this.api_user = new user({

src/api/socket.ts

Lines changed: 22 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ export interface socket_connect_opts {
1616
/** socket value types */
1717
export type socket_value =
1818
| string
19-
| { [key: string]: socket_value }
19+
| { [key: string]: socket_value };
2020

2121
/** a packet sent over the socket */
2222
export interface socket_packet {
@@ -39,7 +39,7 @@ export interface socket_auth_event {
3939
/** relationships */
4040
relationships: {
4141
username: string;
42-
tyoe: user_relationship_status
42+
tyoe: user_relationship_status;
4343
}[];
4444
/** chats */
4545
chats: api_chat[];
@@ -55,8 +55,8 @@ export class socket extends EventEmitter<{
5555
[key: `listener-${string}`]: [socket_packet];
5656
create_message: [post];
5757
edit_message: [post];
58-
delete_message: [{ post_id: string, chat_id: string }];
59-
typing: [{ chat_id: string, username: string }];
58+
delete_message: [{ post_id: string; chat_id: string }];
59+
typing: [{ chat_id: string; username: string }];
6060
auth: [socket_auth_event];
6161
}> {
6262
private socket: WebSocket;
@@ -100,7 +100,7 @@ export class socket extends EventEmitter<{
100100

101101
this.socket.onerror = (err) => this.emit('socket_error', err);
102102

103-
this.on('cmd-post', packet => {
103+
this.on('cmd-post', (packet) => {
104104
try {
105105
const api = packet.val as unknown as api_post;
106106
const p = new post({
@@ -112,9 +112,9 @@ export class socket extends EventEmitter<{
112112
} catch {
113113
// ignore
114114
}
115-
})
115+
});
116116

117-
this.on('cmd-update_post', packet => {
117+
this.on('cmd-update_post', (packet) => {
118118
try {
119119
const api = packet.val as unknown as api_post;
120120
const p = new post({
@@ -126,25 +126,28 @@ export class socket extends EventEmitter<{
126126
} catch {
127127
// ignore
128128
}
129-
})
129+
});
130130

131-
this.on('cmd-delete_post', packet => {
132-
this.emit('delete_message', packet.val as { post_id: string, chat_id: string });
133-
})
131+
this.on('cmd-delete_post', (packet) => {
132+
this.emit(
133+
'delete_message',
134+
packet.val as { post_id: string; chat_id: string },
135+
);
136+
});
134137

135-
this.on('cmd-typing', packet => {
136-
this.emit('typing', packet.val as { chat_id: string, username: string });
137-
})
138+
this.on('cmd-typing', (packet) => {
139+
this.emit('typing', packet.val as { chat_id: string; username: string });
140+
});
138141

139-
this.on('cmd-ulist', packet => {
140-
this.ulist = (packet.val as string).split(';')
141-
})
142+
this.on('cmd-ulist', (packet) => {
143+
this.ulist = (packet.val as string).split(';');
144+
});
142145

143-
this.on('cmd-auth', packet => {
146+
this.on('cmd-auth', (packet) => {
144147
this.emit('auth', packet.val as unknown as socket_auth_event);
145148

146149
this.opts.api_token = (packet.val as unknown as socket_auth_event).token;
147-
})
150+
});
148151
}
149152

150153
static async connect(opts: socket_connect_opts): Promise<socket> {

tests/chat.ts

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ Deno.test('chat construction', async (i) => {
4242
const c = new chat({
4343
api_url: 'http://localhost:8000',
4444
api_token: 'test',
45-
api_username: 'test',
45+
4646
data: regular_chat,
4747
});
4848

@@ -54,7 +54,7 @@ Deno.test('chat leaving', async (i) => {
5454
const c = new chat({
5555
api_url: 'http://localhost:8000',
5656
api_token: 'test',
57-
api_username: 'test',
57+
5858
data: regular_chat,
5959
});
6060

@@ -85,7 +85,7 @@ Deno.test('chat updating', async (i) => {
8585
const c = new chat({
8686
api_url: 'http://localhost:8000',
8787
api_token: 'test',
88-
api_username: 'test',
88+
8989
data: regular_chat,
9090
});
9191

@@ -124,7 +124,7 @@ Deno.test('chat members', async (i) => {
124124
const c = new chat({
125125
api_url: 'http://localhost:8000',
126126
api_token: 'test',
127-
api_username: 'test',
127+
128128
data: regular_chat,
129129
});
130130

@@ -205,7 +205,7 @@ Deno.test('chat messages', async (i) => {
205205
const c = new chat({
206206
api_url: 'http://localhost:8000',
207207
api_token: 'test',
208-
api_username: 'test',
208+
209209
data: regular_chat,
210210
});
211211

@@ -296,14 +296,14 @@ Deno.test('chat search', async (i) => {
296296
const c = new chat({
297297
api_url: 'http://localhost:8000',
298298
api_token: 'test',
299-
api_username: 'test',
299+
300300
data: regular_chat,
301301
});
302302

303303
const h = new chat({
304304
api_url: 'http://localhost:8000',
305305
api_token: 'test',
306-
api_username: 'test',
306+
307307
data: {
308308
...regular_chat,
309309
_id: 'home',

tests/post.ts

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ Deno.test('post construction', async (i) => {
4141
const p = new post({
4242
api_url: 'http://localhost:8000',
4343
api_token: 'test',
44-
api_username: 'test',
44+
4545
data: regular_post,
4646
});
4747

@@ -53,7 +53,7 @@ Deno.test('post pinning', async (i) => {
5353
const p = new post({
5454
api_url: 'http://localhost:8000',
5555
api_token: 'test',
56-
api_username: 'test',
56+
5757
data: regular_post,
5858
});
5959

@@ -116,7 +116,7 @@ Deno.test('post deletion', async (i) => {
116116
const p = new post({
117117
api_url: 'http://localhost:8000',
118118
api_token: 'test',
119-
api_username: 'test',
119+
120120
data: regular_post,
121121
});
122122

@@ -149,7 +149,7 @@ Deno.test('post reporting', async (i) => {
149149
const p = new post({
150150
api_url: 'http://localhost:8000',
151151
api_token: 'test',
152-
api_username: 'test',
152+
153153
data: regular_post,
154154
});
155155

@@ -182,7 +182,7 @@ Deno.test('post editing', async (i) => {
182182
const p = new post({
183183
api_url: 'http://localhost:8000',
184184
api_token: 'test',
185-
api_username: 'test',
185+
186186
data: regular_post,
187187
});
188188

@@ -222,7 +222,7 @@ Deno.test('post reply', async (i) => {
222222
const p = new post({
223223
api_url: 'http://localhost:8000',
224224
api_token: 'test',
225-
api_username: 'test',
225+
226226
data: regular_post,
227227
});
228228

tests/user.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ Deno.test('user construction', async (i) => {
4747
const u = new user({
4848
api_url: 'http://localhost:8000',
4949
api_token: 'test',
50-
api_username: 'test',
50+
5151
data: regular_user,
5252
});
5353

@@ -59,7 +59,7 @@ Deno.test('user reporting', async (i) => {
5959
const u = new user({
6060
api_url: 'http://localhost:8000',
6161
api_token: 'test',
62-
api_username: 'test',
62+
6363
data: regular_user,
6464
});
6565

@@ -86,7 +86,7 @@ Deno.test('user relationship', async (i) => {
8686
const u = new user({
8787
api_url: 'http://localhost:8000',
8888
api_token: 'test',
89-
api_username: 'test',
89+
9090
data: regular_user,
9191
});
9292

@@ -114,7 +114,7 @@ Deno.test('user posts', async (i) => {
114114
const u = new user({
115115
api_url: 'http://localhost:8000',
116116
api_token: 'test',
117-
api_username: 'test',
117+
118118
data: regular_user,
119119
});
120120

0 commit comments

Comments
 (0)