msgpack / msgpack-javascript

@msgpack/msgpack - MessagePack for JavaScript / msgpack.org[JavaScript/TypeScript/ECMA-262]
https://msgpack.org/
ISC License
1.29k stars 161 forks source link

[doc] clarify the edge cases where the input buffer is empty #209

Closed gfx closed 2 years ago

gfx commented 2 years ago

As JSON.parse("") raises a SyntaxError, msgpack.decode([]) raises a RangeError. In fact, it always raises RangeError if the input is insufficient.

resolve #198

codecov-commenter commented 2 years ago

Codecov Report

Merging #209 (bebb16b) into main (b17287d) will not change coverage. The diff coverage is 100.00%.

@@           Coverage Diff           @@
##             main     #209   +/-   ##
=======================================
  Coverage   98.13%   98.13%           
=======================================
  Files          16       16           
  Lines         964      964           
  Branches      206      206           
=======================================
  Hits          946      946           
  Misses         18       18           
Impacted Files Coverage Δ
src/Decoder.ts 99.16% <ø> (ø)
src/decode.ts 100.00% <ø> (ø)
src/decodeAsync.ts 90.47% <100.00%> (ø)

Continue to review full report at Codecov.

Legend - Click here to learn more Δ = absolute <relative> (impact), ø = not affected, ? = missing data Powered by Codecov. Last update b17287d...bebb16b. Read the comment docs.

gfx commented 2 years ago

On the other hand, decodeMulti*() can decode empty inputs, generating an empty stream or array. 2b66bb7a26f5f8377ececf8457a07937b6aa7218