mcollina / msgpack5

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

Error "undefined is not encodable in msgpack" #64

Closed skerit closed 5 years ago

skerit commented 6 years ago

Is there a reason why undefined is so, err, disliked in this package?

I don't seem to be able to register an encoder for it, it's just hard coded in the encoder.js file to throw an error.

The msgpack-node implementation just encodes undefined values to null, and that's what I'd like to accomplish.

mcollina commented 6 years ago

undefined is not null in JS. If you encode an undefined to a null, then when you decode you will not get an undefined.

In this library we support: deepEqual(decode(encode(data)), data).

skerit commented 6 years ago

Of course, but why not let us register an encoder for undefined?

mcollina commented 6 years ago

Would you like to send a pr?