@sockethub/irc2as 4.0.0-alpha.9 → 4.0.0-beta.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +15 -2
- package/dist/as-emitter.d.ts +43 -0
- package/dist/index.d.ts +14 -0
- package/dist/index.js +257 -825
- package/dist/index.js.map +5 -12
- package/package.json +7 -8
- package/src/as-emitter.js +0 -277
- package/src/index.js +0 -308
- package/src/index.test.data.irc.txt +0 -86
- package/src/index.test.data.js +0 -492
- package/src/index.test.js +0 -96
package/src/index.test.data.js
DELETED
|
@@ -1,492 +0,0 @@
|
|
|
1
|
-
export const TestData = [
|
|
2
|
-
{
|
|
3
|
-
context: "irc",
|
|
4
|
-
type: "update",
|
|
5
|
-
actor: {
|
|
6
|
-
type: "service",
|
|
7
|
-
id: "localhost",
|
|
8
|
-
name: "localhost",
|
|
9
|
-
},
|
|
10
|
-
object: {
|
|
11
|
-
type: "topic",
|
|
12
|
-
content: "- -",
|
|
13
|
-
},
|
|
14
|
-
},
|
|
15
|
-
{
|
|
16
|
-
context: "irc",
|
|
17
|
-
type: "update",
|
|
18
|
-
actor: {
|
|
19
|
-
type: "service",
|
|
20
|
-
id: "localhost",
|
|
21
|
-
name: "localhost",
|
|
22
|
-
},
|
|
23
|
-
object: {
|
|
24
|
-
type: "topic",
|
|
25
|
-
content:
|
|
26
|
-
"- on the https://freenode.live website for our call for volunteers and call for - participation. " +
|
|
27
|
-
"If you are interested in sponsoring next year's event, please - send us an e-mail to sponsor@freenode.live " +
|
|
28
|
-
"- - Thank you for using freenode! - -",
|
|
29
|
-
},
|
|
30
|
-
},
|
|
31
|
-
{
|
|
32
|
-
context: "irc",
|
|
33
|
-
type: "update",
|
|
34
|
-
actor: {
|
|
35
|
-
type: "person",
|
|
36
|
-
id: "donkey2018@localhost",
|
|
37
|
-
name: "donkey2018",
|
|
38
|
-
},
|
|
39
|
-
target: { type: "person", id: "slvrbckt@localhost", name: "slvrbckt" },
|
|
40
|
-
object: { type: "address" },
|
|
41
|
-
},
|
|
42
|
-
{
|
|
43
|
-
context: "irc",
|
|
44
|
-
type: "update",
|
|
45
|
-
actor: { type: "person", id: "slvrbckt@localhost", name: "slvrbckt" },
|
|
46
|
-
target: {
|
|
47
|
-
type: "person",
|
|
48
|
-
id: "donkey2018@localhost",
|
|
49
|
-
name: "donkey2018",
|
|
50
|
-
},
|
|
51
|
-
object: { type: "address" },
|
|
52
|
-
},
|
|
53
|
-
{
|
|
54
|
-
context: "irc",
|
|
55
|
-
type: "leave",
|
|
56
|
-
actor: { type: "person", id: "slvrbckt@localhost", name: "slvrbckt" },
|
|
57
|
-
target: { type: "room", id: "localhost/#debian", name: "#debian" },
|
|
58
|
-
object: { type: "message", content: "user has left the channel" },
|
|
59
|
-
},
|
|
60
|
-
{
|
|
61
|
-
context: "irc",
|
|
62
|
-
type: "leave",
|
|
63
|
-
actor: { type: "person", id: "jarlaxl_@localhost", name: "jarlaxl_" },
|
|
64
|
-
target: { type: "service", id: "localhost" },
|
|
65
|
-
object: { type: "message", content: "user has quit" },
|
|
66
|
-
},
|
|
67
|
-
{
|
|
68
|
-
context: "irc",
|
|
69
|
-
type: "join",
|
|
70
|
-
actor: { id: "localhost", type: "service" },
|
|
71
|
-
error: "no such channel sdfsdfsdfsdfsdf",
|
|
72
|
-
target: { id: "sdfsdfsdfsdfsdf@localhost", type: "person" },
|
|
73
|
-
},
|
|
74
|
-
{
|
|
75
|
-
context: "irc",
|
|
76
|
-
type: "update",
|
|
77
|
-
actor: { type: "person", id: "lio17@localhost", name: "lio17" },
|
|
78
|
-
target: {
|
|
79
|
-
type: "room",
|
|
80
|
-
id: "localhost/#kosmos-random",
|
|
81
|
-
name: "#kosmos-random",
|
|
82
|
-
},
|
|
83
|
-
object: { type: "topic", content: "testing123" },
|
|
84
|
-
},
|
|
85
|
-
{
|
|
86
|
-
context: "irc",
|
|
87
|
-
type: "send",
|
|
88
|
-
actor: {
|
|
89
|
-
type: "person",
|
|
90
|
-
id: "hyper_slvrbckt@localhost",
|
|
91
|
-
name: "hyper_slvrbckt",
|
|
92
|
-
},
|
|
93
|
-
target: {
|
|
94
|
-
type: "room",
|
|
95
|
-
id: "localhost/#kosmos-random",
|
|
96
|
-
name: "#kosmos-random",
|
|
97
|
-
},
|
|
98
|
-
object: { type: "message", content: "-ssssssss" },
|
|
99
|
-
},
|
|
100
|
-
{
|
|
101
|
-
context: "irc",
|
|
102
|
-
type: "update",
|
|
103
|
-
actor: { type: "person", id: "lio17@localhost", name: "lio17" },
|
|
104
|
-
target: {
|
|
105
|
-
type: "room",
|
|
106
|
-
id: "localhost/#kosmos-random",
|
|
107
|
-
name: "#kosmos-random",
|
|
108
|
-
},
|
|
109
|
-
object: { type: "topic", content: "no longer boating in senegal" },
|
|
110
|
-
},
|
|
111
|
-
{
|
|
112
|
-
context: "irc",
|
|
113
|
-
type: "send",
|
|
114
|
-
actor: { type: "person", id: "raucao@localhost", name: "raucao" },
|
|
115
|
-
target: {
|
|
116
|
-
type: "room",
|
|
117
|
-
id: "localhost/#kosmos-random",
|
|
118
|
-
name: "#kosmos-random",
|
|
119
|
-
},
|
|
120
|
-
object: {
|
|
121
|
-
type: "me",
|
|
122
|
-
content: "is thinking about sending someone to get b33rz",
|
|
123
|
-
},
|
|
124
|
-
},
|
|
125
|
-
{
|
|
126
|
-
context: "irc",
|
|
127
|
-
type: "update",
|
|
128
|
-
object: { type: "presence", role: "member" },
|
|
129
|
-
actor: {
|
|
130
|
-
type: "person",
|
|
131
|
-
id: "hyper_slvrbckt@localhost",
|
|
132
|
-
name: "hyper_slvrbckt",
|
|
133
|
-
},
|
|
134
|
-
target: {
|
|
135
|
-
type: "room",
|
|
136
|
-
id: "localhost/#kosmos-random",
|
|
137
|
-
name: "#kosmos-random",
|
|
138
|
-
},
|
|
139
|
-
},
|
|
140
|
-
{
|
|
141
|
-
context: "irc",
|
|
142
|
-
type: "update",
|
|
143
|
-
object: { type: "presence", role: "member" },
|
|
144
|
-
actor: {
|
|
145
|
-
type: "person",
|
|
146
|
-
id: "hyper_slvrbckt@localhost",
|
|
147
|
-
name: "hyper_slvrbckt",
|
|
148
|
-
},
|
|
149
|
-
target: {
|
|
150
|
-
type: "room",
|
|
151
|
-
id: "localhost/#kosmos-random",
|
|
152
|
-
name: "#kosmos-random",
|
|
153
|
-
},
|
|
154
|
-
},
|
|
155
|
-
{
|
|
156
|
-
context: "irc",
|
|
157
|
-
type: "update",
|
|
158
|
-
object: { type: "presence", role: "member" },
|
|
159
|
-
actor: {
|
|
160
|
-
type: "person",
|
|
161
|
-
id: "hyper_slvrbckt@localhost",
|
|
162
|
-
name: "hyper_slvrbckt",
|
|
163
|
-
},
|
|
164
|
-
target: {
|
|
165
|
-
type: "room",
|
|
166
|
-
id: "localhost/#kosmos-random",
|
|
167
|
-
name: "#kosmos-random",
|
|
168
|
-
},
|
|
169
|
-
},
|
|
170
|
-
{
|
|
171
|
-
context: "irc",
|
|
172
|
-
type: "update",
|
|
173
|
-
object: { type: "presence", role: "member" },
|
|
174
|
-
actor: {
|
|
175
|
-
type: "person",
|
|
176
|
-
id: "hyper_slvrbckt@localhost",
|
|
177
|
-
name: "hyper_slvrbckt",
|
|
178
|
-
},
|
|
179
|
-
target: {
|
|
180
|
-
type: "room",
|
|
181
|
-
id: "localhost/#kosmos-random",
|
|
182
|
-
name: "#kosmos-random",
|
|
183
|
-
},
|
|
184
|
-
},
|
|
185
|
-
{
|
|
186
|
-
context: "irc",
|
|
187
|
-
type: "update",
|
|
188
|
-
actor: {
|
|
189
|
-
type: "person",
|
|
190
|
-
id: "hyper_slvrbckt@localhost",
|
|
191
|
-
name: "hyper_slvrbckt",
|
|
192
|
-
},
|
|
193
|
-
target: {
|
|
194
|
-
type: "room",
|
|
195
|
-
id: "localhost/#kosmos-random",
|
|
196
|
-
name: "#kosmos-random",
|
|
197
|
-
},
|
|
198
|
-
object: { type: "presence", role: "member" },
|
|
199
|
-
},
|
|
200
|
-
{
|
|
201
|
-
context: "irc",
|
|
202
|
-
type: "update",
|
|
203
|
-
actor: { type: "person", id: "gregkare@localhost", name: "gregkare" },
|
|
204
|
-
target: {
|
|
205
|
-
type: "room",
|
|
206
|
-
id: "localhost/#kosmos-random",
|
|
207
|
-
name: "#kosmos-random",
|
|
208
|
-
},
|
|
209
|
-
object: { type: "presence", role: "member" },
|
|
210
|
-
},
|
|
211
|
-
{
|
|
212
|
-
context: "irc",
|
|
213
|
-
type: "update",
|
|
214
|
-
actor: { type: "person", id: "slvrbckt@localhost", name: "slvrbckt" },
|
|
215
|
-
target: { type: "room", id: "localhost/#kosmos", name: "#kosmos" },
|
|
216
|
-
object: { type: "presence", role: "member" },
|
|
217
|
-
},
|
|
218
|
-
{
|
|
219
|
-
context: "irc",
|
|
220
|
-
type: "update",
|
|
221
|
-
actor: { type: "person", id: "lio17@localhost", name: "lio17" },
|
|
222
|
-
target: { type: "room", id: "localhost/#kosmos", name: "#kosmos" },
|
|
223
|
-
object: { type: "presence", role: "member" },
|
|
224
|
-
},
|
|
225
|
-
{
|
|
226
|
-
context: "irc",
|
|
227
|
-
type: "update",
|
|
228
|
-
actor: {
|
|
229
|
-
type: "person",
|
|
230
|
-
id: "M-silverbucket@localhost",
|
|
231
|
-
name: "M-silverbucket",
|
|
232
|
-
},
|
|
233
|
-
target: { type: "room", id: "localhost/#kosmos", name: "#kosmos" },
|
|
234
|
-
object: { type: "presence", role: "member" },
|
|
235
|
-
},
|
|
236
|
-
{
|
|
237
|
-
context: "irc",
|
|
238
|
-
type: "update",
|
|
239
|
-
actor: { type: "person", id: "botka1@localhost", name: "botka1" },
|
|
240
|
-
target: { type: "room", id: "localhost/#kosmos", name: "#kosmos" },
|
|
241
|
-
object: { type: "presence", role: "member" },
|
|
242
|
-
},
|
|
243
|
-
{
|
|
244
|
-
context: "irc",
|
|
245
|
-
type: "update",
|
|
246
|
-
actor: { type: "person", id: "derbumi@localhost", name: "derbumi" },
|
|
247
|
-
target: { type: "room", id: "localhost/#kosmos", name: "#kosmos" },
|
|
248
|
-
object: { type: "presence", role: "member" },
|
|
249
|
-
},
|
|
250
|
-
{
|
|
251
|
-
context: "irc",
|
|
252
|
-
type: "update",
|
|
253
|
-
actor: { type: "person", id: "ChanServ@localhost", name: "ChanServ" },
|
|
254
|
-
target: { type: "room", id: "localhost/#kosmos", name: "#kosmos" },
|
|
255
|
-
object: { type: "presence", role: "member" },
|
|
256
|
-
},
|
|
257
|
-
{
|
|
258
|
-
context: "irc",
|
|
259
|
-
type: "update",
|
|
260
|
-
actor: { type: "person", id: "gregkare@localhost", name: "gregkare" },
|
|
261
|
-
target: { type: "room", id: "localhost/#kosmos", name: "#kosmos" },
|
|
262
|
-
object: { type: "presence", role: "member" },
|
|
263
|
-
},
|
|
264
|
-
{
|
|
265
|
-
context: "irc",
|
|
266
|
-
type: "update",
|
|
267
|
-
actor: { type: "person", id: "hal8000@localhost", name: "hal8000" },
|
|
268
|
-
target: {
|
|
269
|
-
type: "room",
|
|
270
|
-
id: "localhost/#kosmos-random",
|
|
271
|
-
name: "#kosmos-random",
|
|
272
|
-
},
|
|
273
|
-
object: { type: "presence", role: "member" },
|
|
274
|
-
},
|
|
275
|
-
{
|
|
276
|
-
context: "irc",
|
|
277
|
-
type: "update",
|
|
278
|
-
actor: { type: "person", id: "bkero-@localhost", name: "bkero-" },
|
|
279
|
-
target: { type: "room", id: "localhost/#kosmos", name: "#kosmos" },
|
|
280
|
-
object: { type: "presence", role: "member" },
|
|
281
|
-
},
|
|
282
|
-
{
|
|
283
|
-
context: "irc",
|
|
284
|
-
type: "update",
|
|
285
|
-
actor: { type: "person", id: "galfert@localhost", name: "galfert" },
|
|
286
|
-
target: { type: "room", id: "localhost/#kosmos", name: "#kosmos" },
|
|
287
|
-
object: { type: "presence", role: "member" },
|
|
288
|
-
},
|
|
289
|
-
{
|
|
290
|
-
context: "irc",
|
|
291
|
-
type: "update",
|
|
292
|
-
actor: { type: "person", id: "raucao@localhost", name: "raucao" },
|
|
293
|
-
target: { type: "room", id: "localhost/#kosmos", name: "#kosmos" },
|
|
294
|
-
object: { type: "presence", role: "member" },
|
|
295
|
-
},
|
|
296
|
-
{
|
|
297
|
-
context: "irc",
|
|
298
|
-
type: "update",
|
|
299
|
-
actor: { type: "person", id: "hal8000@localhost", name: "hal8000" },
|
|
300
|
-
target: { type: "room", id: "localhost/#kosmos", name: "#kosmos" },
|
|
301
|
-
object: { type: "presence", role: "member" },
|
|
302
|
-
},
|
|
303
|
-
{
|
|
304
|
-
context: "irc",
|
|
305
|
-
type: "update",
|
|
306
|
-
actor: { type: "person", id: "bkero@localhost", name: "bkero" },
|
|
307
|
-
target: { type: "room", id: "localhost/#kosmos", name: "#kosmos" },
|
|
308
|
-
object: { type: "presence", role: "member" },
|
|
309
|
-
},
|
|
310
|
-
{
|
|
311
|
-
context: "irc",
|
|
312
|
-
type: "update",
|
|
313
|
-
actor: { type: "person", id: "bumi[m]@localhost", name: "bumi[m]" },
|
|
314
|
-
target: { type: "room", id: "localhost/#kosmos", name: "#kosmos" },
|
|
315
|
-
object: { type: "presence", role: "member" },
|
|
316
|
-
},
|
|
317
|
-
{
|
|
318
|
-
context: "irc",
|
|
319
|
-
type: "update",
|
|
320
|
-
actor: { type: "person", id: "slvrbckt@localhost" },
|
|
321
|
-
target: { type: "room", id: "localhost/#debian" },
|
|
322
|
-
error: "You're not a channel operator",
|
|
323
|
-
},
|
|
324
|
-
{
|
|
325
|
-
context: "irc",
|
|
326
|
-
type: "update",
|
|
327
|
-
actor: { type: "person", id: "slvrbckt@localhost" },
|
|
328
|
-
target: { type: "room", id: "localhost/#kosmos-random" },
|
|
329
|
-
error: "You're not a channel operator",
|
|
330
|
-
},
|
|
331
|
-
{
|
|
332
|
-
context: "irc",
|
|
333
|
-
type: "add",
|
|
334
|
-
actor: { type: "person", id: "alice@localhost", name: "alice" },
|
|
335
|
-
target: { type: "person", id: "Kilroy@localhost", name: "Kilroy" },
|
|
336
|
-
object: {
|
|
337
|
-
type: "relationship",
|
|
338
|
-
relationship: "role",
|
|
339
|
-
subject: { type: "presence", role: "owner" },
|
|
340
|
-
object: {
|
|
341
|
-
type: "room",
|
|
342
|
-
id: "localhost/#Finnish",
|
|
343
|
-
name: "#Finnish",
|
|
344
|
-
},
|
|
345
|
-
},
|
|
346
|
-
},
|
|
347
|
-
{
|
|
348
|
-
context: "irc",
|
|
349
|
-
type: "add",
|
|
350
|
-
actor: { type: "person", id: "bob@localhost", name: "bob" },
|
|
351
|
-
target: { type: "person", id: "alice@localhost", name: "alice" },
|
|
352
|
-
object: {
|
|
353
|
-
type: "relationship",
|
|
354
|
-
relationship: "role",
|
|
355
|
-
subject: { type: "presence", role: "participant" },
|
|
356
|
-
object: { type: "room", id: "localhost/#room_a", name: "#room_a" },
|
|
357
|
-
},
|
|
358
|
-
},
|
|
359
|
-
{
|
|
360
|
-
context: "irc",
|
|
361
|
-
type: "add",
|
|
362
|
-
actor: { type: "person", id: "alice@localhost", name: "alice" },
|
|
363
|
-
target: { type: "person", id: "bob@localhost", name: "bob" },
|
|
364
|
-
object: {
|
|
365
|
-
type: "relationship",
|
|
366
|
-
relationship: "role",
|
|
367
|
-
subject: { type: "presence", role: "admin" },
|
|
368
|
-
object: { type: "room", id: "localhost/#room_b", name: "#room_b" },
|
|
369
|
-
},
|
|
370
|
-
},
|
|
371
|
-
{
|
|
372
|
-
context: "irc",
|
|
373
|
-
type: "update",
|
|
374
|
-
target: { type: "room", id: "localhost/#freenode-sponsors" },
|
|
375
|
-
actor: { type: "person", id: "hyper_slvrbckt@localhost" },
|
|
376
|
-
error: "Cannot join channel (+i) - you must be invited",
|
|
377
|
-
},
|
|
378
|
-
{
|
|
379
|
-
context: "irc",
|
|
380
|
-
type: "update",
|
|
381
|
-
target: { type: "service", id: "localhost" },
|
|
382
|
-
error: "Nickname is already in use.",
|
|
383
|
-
actor: { type: "person", id: "nkj@localhost", name: "nkj" },
|
|
384
|
-
},
|
|
385
|
-
{
|
|
386
|
-
context: "irc",
|
|
387
|
-
type: "update",
|
|
388
|
-
target: { type: "service", id: "localhost" },
|
|
389
|
-
error: "Nickname is already in use.",
|
|
390
|
-
actor: { type: "person", id: "slvrbckt@localhost", name: "slvrbckt" },
|
|
391
|
-
},
|
|
392
|
-
{
|
|
393
|
-
context: "irc",
|
|
394
|
-
type: "send",
|
|
395
|
-
actor: { type: "service", id: "localhost" },
|
|
396
|
-
object: {
|
|
397
|
-
type: "message",
|
|
398
|
-
content:
|
|
399
|
-
"This nickname is registered. Please choose a different nickname, or identify via /msg NickServ identify <password>.",
|
|
400
|
-
},
|
|
401
|
-
target: { type: "person", id: "boo@localhost", name: "boo" },
|
|
402
|
-
},
|
|
403
|
-
{
|
|
404
|
-
context: "irc",
|
|
405
|
-
type: "send",
|
|
406
|
-
actor: { type: "service", id: "localhost" },
|
|
407
|
-
object: {
|
|
408
|
-
type: "message",
|
|
409
|
-
content:
|
|
410
|
-
"You have 30 seconds to identify to your nickname before it is changed.",
|
|
411
|
-
},
|
|
412
|
-
target: { type: "person", id: "boo@localhost", name: "boo" },
|
|
413
|
-
},
|
|
414
|
-
{
|
|
415
|
-
context: "irc",
|
|
416
|
-
type: "send",
|
|
417
|
-
actor: { type: "service", id: "localhost" },
|
|
418
|
-
object: {
|
|
419
|
-
type: "message",
|
|
420
|
-
content: "You failed to identify in time for the nickname boo",
|
|
421
|
-
},
|
|
422
|
-
target: { type: "person", id: "boo@localhost", name: "boo" },
|
|
423
|
-
},
|
|
424
|
-
{
|
|
425
|
-
context: "irc",
|
|
426
|
-
type: "update",
|
|
427
|
-
target: { type: "service", id: "localhost" },
|
|
428
|
-
error: "Nick/channel is temporarily unavailable",
|
|
429
|
-
actor: { type: "person", id: "boo@localhost", name: "boo" },
|
|
430
|
-
},
|
|
431
|
-
{
|
|
432
|
-
context: "irc",
|
|
433
|
-
type: "update",
|
|
434
|
-
actor: { type: "person", id: "sh-WjwOE@localhost", name: "sh-WjwOE" },
|
|
435
|
-
target: { type: "person", id: "woooo@localhost", name: "woooo" },
|
|
436
|
-
object: { type: "address" },
|
|
437
|
-
},
|
|
438
|
-
{
|
|
439
|
-
context: "irc",
|
|
440
|
-
type: "send",
|
|
441
|
-
actor: { type: "service", id: "localhost" },
|
|
442
|
-
object: {
|
|
443
|
-
type: "message",
|
|
444
|
-
content:
|
|
445
|
-
"Last login from: ~slvrbckt@localhost on Feb 09 18:45:19 2022 +0000.",
|
|
446
|
-
},
|
|
447
|
-
target: { type: "person", id: "slvrbckt@localhost", name: "slvrbckt" },
|
|
448
|
-
},
|
|
449
|
-
{
|
|
450
|
-
context: "irc",
|
|
451
|
-
type: "join",
|
|
452
|
-
actor: { type: "person", id: "myuser@localhost", name: "myuser" },
|
|
453
|
-
target: {
|
|
454
|
-
type: "room",
|
|
455
|
-
id: "localhost/#kosmos-random",
|
|
456
|
-
name: "#kosmos-random",
|
|
457
|
-
},
|
|
458
|
-
},
|
|
459
|
-
{
|
|
460
|
-
context: "irc",
|
|
461
|
-
type: "update",
|
|
462
|
-
actor: { type: "person", id: "myuser@localhost", name: "myuser" },
|
|
463
|
-
target: {
|
|
464
|
-
type: "room",
|
|
465
|
-
id: "localhost/#kosmos-random",
|
|
466
|
-
name: "#kosmos-random",
|
|
467
|
-
},
|
|
468
|
-
object: { type: "presence", role: "member" },
|
|
469
|
-
},
|
|
470
|
-
{
|
|
471
|
-
context: "irc",
|
|
472
|
-
type: "update",
|
|
473
|
-
actor: { type: "person", id: "botka@localhost", name: "botka" },
|
|
474
|
-
target: {
|
|
475
|
-
type: "room",
|
|
476
|
-
id: "localhost/#kosmos-random",
|
|
477
|
-
name: "#kosmos-random",
|
|
478
|
-
},
|
|
479
|
-
object: { type: "presence", role: "owner" },
|
|
480
|
-
},
|
|
481
|
-
{
|
|
482
|
-
context: "irc",
|
|
483
|
-
type: "update",
|
|
484
|
-
actor: { type: "person", id: "foouser@localhost", name: "foouser" },
|
|
485
|
-
target: {
|
|
486
|
-
type: "room",
|
|
487
|
-
id: "localhost/#kosmos-random",
|
|
488
|
-
name: "#kosmos-random",
|
|
489
|
-
},
|
|
490
|
-
object: { type: "presence", role: "member" },
|
|
491
|
-
},
|
|
492
|
-
];
|
package/src/index.test.js
DELETED
|
@@ -1,96 +0,0 @@
|
|
|
1
|
-
import { beforeEach, describe, expect, it } from "bun:test";
|
|
2
|
-
import { readFileSync } from "fs";
|
|
3
|
-
import { validateActivityStream } from "@sockethub/schemas";
|
|
4
|
-
import equal from "fast-deep-equal";
|
|
5
|
-
|
|
6
|
-
import { IrcToActivityStreams } from "./index.js";
|
|
7
|
-
import { TestData } from "./index.test.data.js";
|
|
8
|
-
const ircdata = readFileSync(__dirname + "/index.test.data.irc.txt", "utf-8");
|
|
9
|
-
const inputs = ircdata.split("\n");
|
|
10
|
-
|
|
11
|
-
function matchStream(done) {
|
|
12
|
-
return (stream) => {
|
|
13
|
-
expect(typeof stream.published).toEqual("string");
|
|
14
|
-
delete stream.published;
|
|
15
|
-
let matched = false;
|
|
16
|
-
for (let i = 0; i <= TestData.length; i++) {
|
|
17
|
-
matched = equal(stream, TestData[i]);
|
|
18
|
-
if (matched) {
|
|
19
|
-
// when matched, remove output entry from list
|
|
20
|
-
TestData.splice(i, 1);
|
|
21
|
-
break;
|
|
22
|
-
}
|
|
23
|
-
}
|
|
24
|
-
if (!matched) {
|
|
25
|
-
console.log();
|
|
26
|
-
console.log("available matches:" + JSON.stringify(TestData));
|
|
27
|
-
console.log("failed to find match for: " + JSON.stringify(stream));
|
|
28
|
-
return done(new Error("failed matching " + JSON.stringify(stream)));
|
|
29
|
-
}
|
|
30
|
-
const err = validateActivityStream(stream);
|
|
31
|
-
if (err) {
|
|
32
|
-
return done(new Error(err + " - " + JSON.stringify(stream)));
|
|
33
|
-
}
|
|
34
|
-
};
|
|
35
|
-
}
|
|
36
|
-
|
|
37
|
-
describe("IrcToActivityStreams", () => {
|
|
38
|
-
let irc2as,
|
|
39
|
-
pongs = 0,
|
|
40
|
-
pings = 0;
|
|
41
|
-
beforeEach(() => {
|
|
42
|
-
irc2as = new IrcToActivityStreams({ server: "localhost" });
|
|
43
|
-
expect(irc2as).toHaveProperty("events");
|
|
44
|
-
expect(typeof irc2as.events.on).toEqual("function");
|
|
45
|
-
irc2as.events.on("unprocessed", (string) => {
|
|
46
|
-
console.log("unprocessed> " + string);
|
|
47
|
-
});
|
|
48
|
-
irc2as.events.on("pong", () => {
|
|
49
|
-
pongs++;
|
|
50
|
-
});
|
|
51
|
-
irc2as.events.on("ping", () => {
|
|
52
|
-
pings++;
|
|
53
|
-
});
|
|
54
|
-
});
|
|
55
|
-
|
|
56
|
-
describe("inputs generate expected outputs", () => {
|
|
57
|
-
it("inputs generate expected outputs", (done) => {
|
|
58
|
-
irc2as.events.on("incoming", matchStream(done));
|
|
59
|
-
irc2as.events.on("error", matchStream(done));
|
|
60
|
-
for (let i = 0; inputs.length > i; i++) {
|
|
61
|
-
irc2as.input(inputs[i]);
|
|
62
|
-
}
|
|
63
|
-
setTimeout(() => {
|
|
64
|
-
expect(TestData.length).toEqual(0);
|
|
65
|
-
done();
|
|
66
|
-
}, 0);
|
|
67
|
-
});
|
|
68
|
-
it("ping and pong count", () => {
|
|
69
|
-
expect(pings).toEqual(2);
|
|
70
|
-
expect(pongs).toEqual(3);
|
|
71
|
-
});
|
|
72
|
-
});
|
|
73
|
-
|
|
74
|
-
describe("handle many room joins", () => {
|
|
75
|
-
let totalCount = 0;
|
|
76
|
-
it("send join messages", (done) => {
|
|
77
|
-
irc2as.events.on("incoming", () => {
|
|
78
|
-
totalCount += 1;
|
|
79
|
-
if (totalCount === 5 * 100) {
|
|
80
|
-
done();
|
|
81
|
-
}
|
|
82
|
-
});
|
|
83
|
-
for (let i = 0; i < 5; i++) {
|
|
84
|
-
let names =
|
|
85
|
-
":hitchcock.freenode.net 353 hyper_slvrbckt @ #kosmos-random :hyper_slvrbckt ";
|
|
86
|
-
for (let n = 0; n < 100; n++) {
|
|
87
|
-
names += ` gregkare${i}${n} hal8000${i}${n} botka${i}${n} raucao${i}${n} galfert${i}${n}`;
|
|
88
|
-
}
|
|
89
|
-
irc2as.input(names);
|
|
90
|
-
}
|
|
91
|
-
irc2as.input(
|
|
92
|
-
":hitchcock.freenode.net 366 hyper_slvrbckt #kosmos-random :End of /NAMES list.",
|
|
93
|
-
);
|
|
94
|
-
});
|
|
95
|
-
});
|
|
96
|
-
});
|