Skip to content

Commit

Permalink
chore: use upstream types for compact-encoding (#813)
Browse files Browse the repository at this point in the history
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
  • Loading branch information
EvanHahn authored Sep 9, 2024
1 parent 52d8449 commit 9b72be8
Show file tree
Hide file tree
Showing 4 changed files with 12 additions and 21 deletions.
8 changes: 8 additions & 0 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -111,6 +111,7 @@
"@sinonjs/fake-timers": "^10.0.2",
"@types/b4a": "^1.6.0",
"@types/bogon": "^1.0.2",
"@types/compact-encoding": "^2.15.0",
"@types/debug": "^4.1.8",
"@types/json-schema": "^7.0.11",
"@types/json-stable-stringify": "^1.0.36",
Expand Down
1 change: 0 additions & 1 deletion types/compact-encoding.d.ts

This file was deleted.

23 changes: 3 additions & 20 deletions types/protomux.d.ts
Original file line number Diff line number Diff line change
@@ -1,30 +1,13 @@
declare module 'protomux' {
import { Duplex } from 'streamx'
import { Duplex as NodeDuplex } from 'stream'

interface PreEncodingState {
buffer: null
start: number
end: number
}

interface EncodingState {
buffer: null | Buffer
start: number
end: number
}

interface Encoding {
preencode(state: PreEncodingState, value: any): void
encode(state: EncodingState, value: any): void
decode(state: EncodingState): any
}
import type cenc from 'compact-encoding'

interface Message {
type: number
send(msg: any): void
onmessage: (message: any) => void
encoding: Encoding
encoding: cenc.Encoder
}

type MessageOptions = Partial<Pick<Message, 'onmessage' | 'encoding'>>
Expand Down Expand Up @@ -65,7 +48,7 @@ declare module 'protomux' {
aliases?: string[]
id?: null | Buffer
unique?: boolean
handshake?: Encoding
handshake?: cenc.Encoder
messages: MessageOptions[]
onopen?(handshake?: any): Promise<void> | void
onclose?(): Promise<void> | void
Expand Down

0 comments on commit 9b72be8

Please sign in to comment.