darrachequesne / notepack

A fast Node.js implementation of the latest MessagePack spec
MIT License
75 stars 19 forks source link

Support for actual int64 as opposed to int53 #21

Open rochdev opened 3 years ago

rochdev commented 3 years ago

I was wondering if support for int64 libraries like long and int64-buffer would be considered. I'm willing to open a PR for int64-buffer since it's what we use and is also used by msgpack-lite.

This would not add a lot of overhead to the library and would look something like this:

if (value._isUint64BE) {
  value = value.toArray();
  bytes.push(0xcf, value[0], value[1], value[2], value[3], value[4], value[5], value[6], value[7]);
  return 9;
}
rochdev commented 3 years ago

@darrachequesne Thoughts?

slavaGanzin commented 3 years ago

@rochdev create a PR. It's always easier to talk about working code.

p.s. I have no relation to maintainer.

rochdev commented 3 years ago

Opened #22

darrachequesne commented 3 years ago

That's an interesting idea! My only concern is the impact on the bundle size, for the browser build. Would custom encoders (suggested here: https://github.com/darrachequesne/notepack/issues/18) help?

rochdev commented 3 years ago

Good point. I'll have to check if we could use something like that with our requirements (which are a bit complicated) and will report back. Having an external implementation for custom encoding would definitely remove a lot of the decisions related to built-in support.