Skip to content

Commit b6a9c18

Browse files
committed
chore: fix generated code
1 parent caa0d71 commit b6a9c18

File tree

1 file changed

+23
-17
lines changed
  • packages/protons-benchmark/src/protons

1 file changed

+23
-17
lines changed

packages/protons-benchmark/src/protons/bench.ts

+23-17
Original file line numberDiff line numberDiff line change
@@ -2,23 +2,25 @@
22
/* eslint-disable @typescript-eslint/no-namespace */
33

44
import { encodeMessage, decodeMessage, message, uint32, enumeration, string, bytes } from 'protons-runtime'
5+
import type { Codec } from 'protons-runtime'
6+
import type { Uint8ArrayList } from 'uint8arraylist'
57

68
export interface Foo {
79
baz: number
810
}
911

1012
export namespace Foo {
11-
export const codec = () => {
13+
export const codec = (): Codec<Foo> => {
1214
return message<Foo>({
1315
1: { name: 'baz', codec: uint32 }
1416
})
1517
}
1618

17-
export const encode = (obj: Foo): Uint8Array => {
19+
export const encode = (obj: Foo): Uint8ArrayList => {
1820
return encodeMessage(obj, Foo.codec())
1921
}
2022

21-
export const decode = (buf: Uint8Array): Foo => {
23+
export const decode = (buf: Uint8Array | Uint8ArrayList): Foo => {
2224
return decodeMessage(buf, Foo.codec())
2325
}
2426
}
@@ -28,17 +30,17 @@ export interface Bar {
2830
}
2931

3032
export namespace Bar {
31-
export const codec = () => {
33+
export const codec = (): Codec<Bar> => {
3234
return message<Bar>({
3335
1: { name: 'tmp', codec: Foo.codec() }
3436
})
3537
}
3638

37-
export const encode = (obj: Bar): Uint8Array => {
39+
export const encode = (obj: Bar): Uint8ArrayList => {
3840
return encodeMessage(obj, Bar.codec())
3941
}
4042

41-
export const decode = (buf: Uint8Array): Bar => {
43+
export const decode = (buf: Uint8Array | Uint8ArrayList): Bar => {
4244
return decodeMessage(buf, Bar.codec())
4345
}
4446
}
@@ -48,28 +50,32 @@ export enum FOO {
4850
ABE = 'ABE'
4951
}
5052

53+
enum __FOOValues {
54+
LOL = 1,
55+
ABE = 3
56+
}
57+
5158
export namespace FOO {
5259
export const codec = () => {
53-
return enumeration<typeof FOO>(FOO)
60+
return enumeration<typeof FOO>(__FOOValues)
5461
}
5562
}
56-
5763
export interface Yo {
5864
lol: FOO[]
5965
}
6066

6167
export namespace Yo {
62-
export const codec = () => {
68+
export const codec = (): Codec<Yo> => {
6369
return message<Yo>({
6470
1: { name: 'lol', codec: FOO.codec(), repeats: true }
6571
})
6672
}
6773

68-
export const encode = (obj: Yo): Uint8Array => {
74+
export const encode = (obj: Yo): Uint8ArrayList => {
6975
return encodeMessage(obj, Yo.codec())
7076
}
7177

72-
export const decode = (buf: Uint8Array): Yo => {
78+
export const decode = (buf: Uint8Array | Uint8ArrayList): Yo => {
7379
return decodeMessage(buf, Yo.codec())
7480
}
7581
}
@@ -80,18 +86,18 @@ export interface Lol {
8086
}
8187

8288
export namespace Lol {
83-
export const codec = () => {
89+
export const codec = (): Codec<Lol> => {
8490
return message<Lol>({
8591
1: { name: 'lol', codec: string },
8692
2: { name: 'b', codec: Bar.codec() }
8793
})
8894
}
8995

90-
export const encode = (obj: Lol): Uint8Array => {
96+
export const encode = (obj: Lol): Uint8ArrayList => {
9197
return encodeMessage(obj, Lol.codec())
9298
}
9399

94-
export const decode = (buf: Uint8Array): Lol => {
100+
export const decode = (buf: Uint8Array | Uint8ArrayList): Lol => {
95101
return decodeMessage(buf, Lol.codec())
96102
}
97103
}
@@ -104,7 +110,7 @@ export interface Test {
104110
}
105111

106112
export namespace Test {
107-
export const codec = () => {
113+
export const codec = (): Codec<Test> => {
108114
return message<Test>({
109115
6: { name: 'meh', codec: Lol.codec() },
110116
3: { name: 'hello', codec: uint32 },
@@ -113,11 +119,11 @@ export namespace Test {
113119
})
114120
}
115121

116-
export const encode = (obj: Test): Uint8Array => {
122+
export const encode = (obj: Test): Uint8ArrayList => {
117123
return encodeMessage(obj, Test.codec())
118124
}
119125

120-
export const decode = (buf: Uint8Array): Test => {
126+
export const decode = (buf: Uint8Array | Uint8ArrayList): Test => {
121127
return decodeMessage(buf, Test.codec())
122128
}
123129
}

0 commit comments

Comments
 (0)