Skip to content

Commit 9b72be8

Browse files
authored
chore: use upstream types for compact-encoding (#813)
This is a types-only change. [`@types/compact-encoding`][0] was recently published. Let's use that instead of our "empty" type. [0]: https://www.npmjs.com/package/@types/compact-encoding
1 parent 52d8449 commit 9b72be8

File tree

4 files changed

+12
-21
lines changed

4 files changed

+12
-21
lines changed

package-lock.json

Lines changed: 8 additions & 0 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 & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -111,6 +111,7 @@
111111
"@sinonjs/fake-timers": "^10.0.2",
112112
"@types/b4a": "^1.6.0",
113113
"@types/bogon": "^1.0.2",
114+
"@types/compact-encoding": "^2.15.0",
114115
"@types/debug": "^4.1.8",
115116
"@types/json-schema": "^7.0.11",
116117
"@types/json-stable-stringify": "^1.0.36",

types/compact-encoding.d.ts

Lines changed: 0 additions & 1 deletion
This file was deleted.

types/protomux.d.ts

Lines changed: 3 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -1,30 +1,13 @@
11
declare module 'protomux' {
22
import { Duplex } from 'streamx'
33
import { Duplex as NodeDuplex } from 'stream'
4-
5-
interface PreEncodingState {
6-
buffer: null
7-
start: number
8-
end: number
9-
}
10-
11-
interface EncodingState {
12-
buffer: null | Buffer
13-
start: number
14-
end: number
15-
}
16-
17-
interface Encoding {
18-
preencode(state: PreEncodingState, value: any): void
19-
encode(state: EncodingState, value: any): void
20-
decode(state: EncodingState): any
21-
}
4+
import type cenc from 'compact-encoding'
225

236
interface Message {
247
type: number
258
send(msg: any): void
269
onmessage: (message: any) => void
27-
encoding: Encoding
10+
encoding: cenc.Encoder
2811
}
2912

3013
type MessageOptions = Partial<Pick<Message, 'onmessage' | 'encoding'>>
@@ -65,7 +48,7 @@ declare module 'protomux' {
6548
aliases?: string[]
6649
id?: null | Buffer
6750
unique?: boolean
68-
handshake?: Encoding
51+
handshake?: cenc.Encoder
6952
messages: MessageOptions[]
7053
onopen?(handshake?: any): Promise<void> | void
7154
onclose?(): Promise<void> | void

0 commit comments

Comments
 (0)