Skip to content

Commit

Permalink
chore: update decodeStream
Browse files Browse the repository at this point in the history
  • Loading branch information
zdm committed Dec 22, 2024
1 parent 984d3db commit 023849c
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 7 deletions.
6 changes: 3 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -46,10 +46,10 @@ Throws error if unable to decode message.
- `data` {Buffer|ArrayBuffer|Uint8Array|string} Data to decode.
- `offset?` {integer} Offset of the message start in the passed data. **Default:** `0`.
- Returns: {Object}:
- `value?` {any} Decoded data.
- `offset?` {integer} Offset of the decoded message end in the passed data.
- `value` {any} Decoded data.
- `offset` {integer} Offset of the decoded message end in the passed data.

Returns empty {Object} if message is incomplete.
Returns {undefined} if message is incomplete.

Throws error if unable to decode message.

Expand Down
6 changes: 3 additions & 3 deletions docs/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -42,10 +42,10 @@ Throws error if unable to decode message.
- `data` {Buffer|ArrayBuffer|Uint8Array|string} Data to decode.
- `offset?` {integer} Offset of the message start in the passed data. **Default:** `0`.
- Returns: {Object}:
- `value?` {any} Decoded data.
- `offset?` {integer} Offset of the decoded message end in the passed data.
- `value` {any} Decoded data.
- `offset` {integer} Offset of the decoded message end in the passed data.

Returns empty {Object} if message is incomplete.
Returns {undefined} if message is incomplete.

Throws error if unable to decode message.

Expand Down
2 changes: 1 addition & 1 deletion lib/decode.js
Original file line number Diff line number Diff line change
Expand Up @@ -436,7 +436,7 @@ export function decodeStream ( buffer, offset ) {

// message is incomplete
if ( decoder.rangeError || e.code === "ERR_BUFFER_OUT_OF_BOUNDS" || e.code === "ERR_OUT_OF_RANGE" ) {
return {};
return;
}

throw e;
Expand Down

0 comments on commit 023849c

Please sign in to comment.