mcollina / msgpack5

A msgpack v5 implementation for node.js, with extension points / msgpack.org[Node]
MIT License
492 stars 76 forks source link

Adds support for signed int64 encoding/decoding #38

Closed mdouglass closed 8 years ago

mdouglass commented 8 years ago

This patch adds support for signed int64 encoding and decoding.

Some potential flags I'm aware of:

1) The two's complement code is based off of the implementation from node-int64. This is MIT-licensed so would be compatible. The relevant code could also be replaced with an alternate implementation, I just haven't had time to do that yet.

2) The decoder does not validate that the decoded int64 is in the Number.MIN_SAFE_INTEGER..Number.MAX_SAFE_INTEGER range. It would be potentially nice to do that and throw a decode exception, but was not necessary for my use case.

Thanks! Matthew

Enet4 commented 8 years ago

I have tested this pull request just a moment ago, and that fix should definitely become official. Meanwhile, I took the advice of making sure that the number lies in the safe range here.