-
Notifications
You must be signed in to change notification settings - Fork 26
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
feat: rework typescript generator & add suite #46
base: main
Are you sure you want to change the base?
Conversation
27b5572
to
dd05a75
Compare
9a6ea57
to
6c2f861
Compare
Thanks @MrFoxPro for your work. It looks like the lint error is on |
Yep, PR requires some polishing |
I thought one way to speedup encoding is to preallocate chunk for fixed-size values of type by recursive lookup of it in code generator and adding flag to "noAlloc" in |
61ed1e6
to
4c9f0c3
Compare
667bb00
to
591dc0c
Compare
I decided to change TypeScript implementation. Now it looks like this: enum MultiEnum {
VariantA(i32),
VariantB(String),
VariantC { x: u8, y: f64 },
UnitVariant,
}
struct ComplexStruct {
inner: SimpleStruct,
flag: bool,
items: Vec<MultiEnum>,
unit: UnitStruct,
newtype: NewtypeStruct,
tuple: TupleStruct,
tupple_inline: (String, i32),
map: HashMap<i32, i64>
} -> export const ComplexStruct_obj: Registry.ComplexStruct = {
inner: { a: 42, b: "Hello" },
flag: true,
items: [
{ $: "variant_a", $0: 10 },
{ $: "variant_b", $0: "World" }
],
unit: null,
newtype: 99,
tuple: { $0: 123, $1: 45.67, $2: "Test" },
tupple_inline: { $0: "SomeString", $1: 777 },
map: new Map().set(3, 7n)
} |
591dc0c
to
89dbcaf
Compare
Closes #43
Probably needs more tests
Checkout
suite/typescript/ts/test.ts
andsuite/typescript/readme.md
for example usage and additional informationYou can fix and adjust as you want if you have time
Benchamrks:
Encode
Decode
Need investigation how to improve encoding.
It's worth to look into protobuf-js implementation