-
Notifications
You must be signed in to change notification settings - Fork 2
Open
Description
Consider
cryptian/src/transform/block.ts
Lines 33 to 34 in 1393bc5
| const remain = blockSize + ((data.length % blockSize) || blockSize); | |
| const align = data.length > remain ? data.length - remain : 0; |
Here
remain is the amount of data to store and combine with the next chunk once it arrives, and align is the amount of data to process in this _transform call. I don't see why it should ever be necessary to store more than one blockSize for later. Doesn't it suffice to do
const remain = data.length % blockSize;
const align = data.length - remain; ? Not that the current code is wrong - after the final flush, everything sorts out - but it adds unnecessary latency which may prevent this from working in a duplex communication scenario. (I.e. I'm waiting to receive an answer to my last request before sending the next request, but my last request or the last answer are "stuck" in the transform.)
Metadata
Metadata
Assignees
Labels
No labels