bigeasy / packet

Incremental binary parsers and serializers for Node.js.
http://bigeasy.github.io/packet
MIT License
186 stars 25 forks source link

Empty array should yield empty output #590

Closed sukovec closed 3 years ago

sukovec commented 3 years ago

Hello,

I find your library pretty useful, but there is one thing that I believe may be a bug. An empty length-prefixed array should yield just the prefix.

For example: Pattern: l8 => numero, l8/l8 => arr, l8 => other Test object: { "numero": 8, "arr": [], "other": 10 } Output: <Buffer 08 00 00 0a> Expected output: <Buffer 08 00 0a>

Maybe I misunderstood or missed something, but I would expect, that empty array with length 0 contains nothing, not even a zero as it is a array with one (yet useless) item.