ipfs / protons

Protocol Buffers for Node.js and the browser without eval
Other
32 stars 23 forks source link

Support 64 bit int/fixed as number #112

Closed wemeetagain closed 12 months ago

wemeetagain commented 1 year ago

In order to be performant in certain usecases, we need to be able to force generated code to use number instead of bigint.

Protons should be extended to support a field option named jstype used like so:

message Foo {
  uint64 bar = 1 [jstype = JS_NUMBER];
}
import { Foo } from './foo.js'

const foo = {
  bar: 100 // a number :)
}

typeof Foo.decode(Foo.encode(foo)).bar === 'number'

See