mcollina / msgpack5

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

Fixed Stream decode C0 byte (nil) processing error #68

Closed i-kovalyov closed 6 years ago

i-kovalyov commented 6 years ago

Fixed Stream decode processing error: after C0 byte (nil) stream switched to "End of stream state", added test. Minor changes made in modules formatting to satisfy modules formatting rules checked in tests.

mcollina commented 6 years ago

Can you also add the same for the encoder?

i-kovalyov commented 6 years ago

Sorry, to confirm for encoder. Do you want to add "unwrap" option for encoder? Using unwrap = true encoder can encode obj.value instead of obj.

Using this option we can pass decoder output to encoder.

mcollina commented 6 years ago

The overall goal is to have source.pipe(encoder).pipe(decoder).pipe(sink) have the same input/output sata. I would keep the name of the option the same, but do what make sense to you.

i-kovalyov commented 6 years ago

Sorry, don't understand how to get same input and output data in this scanario: source.pipe(encoder).pipe(decoder({wrap:true})).pipe(sink).

For example when I pass null to encoder it will translate it to C0 byte, then decoder will decode C0 byte to {value:null}. I can't translate output to null using extra transformation at encoder level.

Can you explain please?

mcollina commented 6 years ago

What I mean is that the encode takes objects in the form of { value }.

mcollina commented 6 years ago

Can you please rebase? This now conflicts with master.