WARNING: THIS SITE IS A MIRROR OF GITHUB.COM / IT CANNOT LOGIN OR REGISTER ACCOUNTS / THE CONTENTS ARE PROVIDED AS-IS / THIS SITE ASSUMES NO RESPONSIBILITY FOR ANY DISPLAYED CONTENT OR LINKS / IF YOU FOUND SOMETHING MAY NOT GOOD FOR EVERYONE, CONTACT ADMIN AT ilovescratch@foxmail.com
Skip to content

Commit 443be33

Browse files
committed
update: deps, adopt new stz practices
1 parent 38b2e71 commit 443be33

File tree

10 files changed

+115
-133
lines changed

10 files changed

+115
-133
lines changed

package-lock.json

Lines changed: 4 additions & 4 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@
3434
},
3535
"dependencies": {
3636
"@e280/sten": "^0.0.0-6",
37-
"@e280/stz": "^0.2.12",
37+
"@e280/stz": "^0.2.13",
3838
"ws": "^8.18.3"
3939
},
4040
"devDependencies": {

s/tools/pingponger.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11

2-
import {deadline, defer, Deferred, IdCounter, nap, sub, repeat} from "@e280/stz"
2+
import {deadline, defer, Deferred, IdCounter, nap, sub, cycle} from "@e280/stz"
33
import {Averager} from "./averager.js"
44
import {appropriateHeartbeat} from "./appropriate-heartbeat.js"
55

@@ -60,7 +60,7 @@ export class Pingponger {
6060
/** start an ongoing heartbeat */
6161
heartbeat(onTimeout: (error: any) => void = () => {}) {
6262
const ms = appropriateHeartbeat(this.options.timeout)
63-
return repeat(async stop => {
63+
return cycle(async stop => {
6464
try {
6565
await this.ping()
6666
await nap(ms)

s/tools/random-user-emojis.ts

Lines changed: 88 additions & 86 deletions
Original file line numberDiff line numberDiff line change
@@ -1,92 +1,94 @@
11

2-
import {Hat} from "@e280/stz"
2+
import {Dispenser} from "@e280/stz"
33

4-
export class RandomUserEmojis extends Hat<string> {
4+
export class RandomUserEmojis extends Dispenser<string> {
55
constructor() {
6-
super([
7-
"🐶",
8-
"🐕",
9-
"🐩",
10-
"🐺",
11-
"🦊",
12-
"🦝",
13-
"🐱",
14-
"🐈",
15-
"🐯",
16-
"🐅",
17-
"🐆",
18-
"🐴",
19-
"🐎",
20-
"🦄",
21-
"🦓",
22-
"🦍",
23-
"🦧",
24-
"🦣",
25-
"🐘",
26-
"🦏",
27-
"🦛",
28-
"🐭",
29-
"🐁",
30-
"🐀",
31-
"🐹",
32-
"🐰",
33-
"🐇",
34-
"🦨",
35-
"🦡",
36-
"🦘",
37-
"🦙",
38-
"🐿️",
39-
"🦦",
40-
"🦥",
41-
"🐻",
42-
"🐨",
43-
"🐼",
44-
"🦫",
45-
"🐷",
46-
"🐽",
47-
"🐖",
48-
"🐗",
49-
"🐮",
50-
"🐄",
51-
"🐃",
52-
"🐂",
53-
"🦌",
54-
"🐐",
55-
"🐏",
56-
"🐑",
57-
"🐪",
58-
"🐫",
59-
"🐦",
60-
"🐧",
61-
"🦅",
62-
"🦆",
63-
"🦢",
64-
"🦉",
65-
"🦩",
66-
"🦤",
67-
"🐸",
68-
"🦎",
69-
"🐢",
70-
"🐍",
71-
"🐊",
72-
"🐠",
73-
"🐟",
74-
"🦈",
75-
"🐡",
76-
"🐬",
77-
"🐋",
78-
"🐳",
79-
"🐞",
80-
"🐜",
81-
"🐝",
82-
"🦋",
83-
"🐌",
84-
"🦗",
85-
"🪲",
86-
"🦟",
87-
"🦠",
88-
"🫃",
89-
])
6+
super(() => emojis)
907
}
918
}
929

10+
const emojis = [
11+
"🐶",
12+
"🐕",
13+
"🐩",
14+
"🐺",
15+
"🦊",
16+
"🦝",
17+
"🐱",
18+
"🐈",
19+
"🐯",
20+
"🐅",
21+
"🐆",
22+
"🐴",
23+
"🐎",
24+
"🦄",
25+
"🦓",
26+
"🦍",
27+
"🦧",
28+
"🦣",
29+
"🐘",
30+
"🦏",
31+
"🦛",
32+
"🐭",
33+
"🐁",
34+
"🐀",
35+
"🐹",
36+
"🐰",
37+
"🐇",
38+
"🦨",
39+
"🦡",
40+
"🦘",
41+
"🦙",
42+
"🐿️",
43+
"🦦",
44+
"🦥",
45+
"🐻",
46+
"🐨",
47+
"🐼",
48+
"🦫",
49+
"🐷",
50+
"🐽",
51+
"🐖",
52+
"🐗",
53+
"🐮",
54+
"🐄",
55+
"🐃",
56+
"🐂",
57+
"🦌",
58+
"🐐",
59+
"🐏",
60+
"🐑",
61+
"🐪",
62+
"🐫",
63+
"🐦",
64+
"🐧",
65+
"🦅",
66+
"🦆",
67+
"🦢",
68+
"🦉",
69+
"🦩",
70+
"🦤",
71+
"🐸",
72+
"🦎",
73+
"🐢",
74+
"🐍",
75+
"🐊",
76+
"🐠",
77+
"🐟",
78+
"🦈",
79+
"🐡",
80+
"🐬",
81+
"🐋",
82+
"🐳",
83+
"🐞",
84+
"🐜",
85+
"🐝",
86+
"🦋",
87+
"🐌",
88+
"🦗",
89+
"🪲",
90+
"🦟",
91+
"🦠",
92+
"🫃",
93+
]
94+
Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,22 +1,18 @@
11

2-
import {Trash} from "@e280/stz"
2+
import {disposer} from "@e280/stz"
33
import {Conduit} from "./conduit.js"
44
import {onMessage} from "../parts/helpers.js"
55

66
export class BroadcastConduit extends Conduit {
7-
#trash = new Trash()
7+
dispose = disposer()
88

99
constructor(channel: BroadcastChannel) {
1010
super()
11-
this.#trash.add(
11+
this.dispose.schedule(
1212
this.sendRequest.sub(m => channel.postMessage(m)),
1313
this.sendResponse.sub(m => channel.postMessage(m)),
1414
onMessage(channel, e => this.recv(e.data, e)),
1515
)
1616
}
17-
18-
dispose() {
19-
this.#trash.dispose()
20-
}
2117
}
2218

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,23 +1,19 @@
11

2-
import {Trash} from "@e280/stz"
2+
import {disposer} from "@e280/stz"
33
import {Conduit} from "./conduit.js"
44
import {PostableChannel} from "../types.js"
55
import {onMessage} from "../parts/helpers.js"
66

77
export class PostableConduit extends Conduit {
8-
#trash = new Trash()
8+
dispose = disposer()
99

1010
constructor(channel: PostableChannel) {
1111
super()
12-
this.#trash.add(
12+
this.dispose.schedule(
1313
this.sendRequest.sub((m, transfer) => channel.postMessage(m, transfer)),
1414
this.sendResponse.sub((m, transfer) => channel.postMessage(m, transfer)),
1515
onMessage(channel, e => this.recv(e.data, e)),
1616
)
1717
}
18-
19-
dispose() {
20-
this.#trash.dispose()
21-
}
2218
}
2319

s/transports/messenger/conduits/websocket.ts

Lines changed: 7 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11

22
import type * as ws from "ws"
3-
import {Trash, ev} from "@e280/stz"
3+
import {disposer, ev} from "@e280/stz"
44

55
import {Conduit} from "./conduit.js"
66
import {JsonRpc} from "../../../core/json-rpc.js"
@@ -13,7 +13,9 @@ type Message = InfraMessage | RpcMessage
1313
export class WebsocketConduit extends Conduit {
1414
socket: WebSocket | ws.WebSocket
1515
pingponger: Pingponger
16-
#trash = new Trash()
16+
17+
/** clean up this conduit, detaching socket listeners. does not close the socket. */
18+
dispose = disposer()
1719

1820
constructor(options: {
1921
socket: WebSocket | ws.WebSocket
@@ -26,13 +28,13 @@ export class WebsocketConduit extends Conduit {
2628
this.socket = options.socket
2729

2830
// sending rpc messages
29-
this.#trash.add(
31+
this.dispose.schedule(
3032
this.sendRequest.sub(this.#sendRpc),
3133
this.sendResponse.sub(this.#sendRpc),
3234
)
3335

3436
// listening to socket events
35-
this.#trash.add(
37+
this.dispose.schedule(
3638
ev(this.socket, {
3739
error: error => {
3840
this.dispose()
@@ -55,7 +57,7 @@ export class WebsocketConduit extends Conduit {
5557
})
5658

5759
// establish pingponger heartbeat
58-
this.#trash.add(
60+
this.dispose.schedule(
5961
this.pingponger.heartbeat(() => {
6062
if (this.socket.readyState === 1)
6163
this.socket.close()
@@ -86,10 +88,5 @@ export class WebsocketConduit extends Conduit {
8688
throw new Error("message listener")
8789
}
8890
}
89-
90-
/** clean up this conduit, detaching socket listeners. does not close the socket. */
91-
dispose() {
92-
this.#trash.dispose()
93-
}
9491
}
9592

s/transports/messenger/conduits/window.ts

Lines changed: 3 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,12 @@
11

2-
import {Trash} from "@e280/stz"
2+
import {disposer} from "@e280/stz"
33
import {Conduit} from "./conduit.js"
44
import {ChannelMessage} from "../types.js"
55
import {onMessage} from "../parts/helpers.js"
66

77
export class WindowConduit extends Conduit {
8-
#trash = new Trash()
9-
108
targetOrigin: string
9+
dispose = disposer()
1110

1211
constructor(options: {
1312
localWindow: Window
@@ -20,7 +19,7 @@ export class WindowConduit extends Conduit {
2019
const {localWindow, targetWindow, allow} = options
2120
this.targetOrigin = options.targetOrigin
2221

23-
this.#trash.add(
22+
this.dispose.schedule(
2423
this.sendRequest.sub((m, transfer) =>
2524
targetWindow.postMessage(m, this.targetOrigin, transfer)),
2625

@@ -33,9 +32,5 @@ export class WindowConduit extends Conduit {
3332
}),
3433
)
3534
}
36-
37-
dispose() {
38-
this.#trash.dispose()
39-
}
4035
}
4136

0 commit comments

Comments
 (0)