Uh oh!
There was an error while loading. Please reload this page.
- Notifications
You must be signed in to change notification settings - Fork 34.2k
Closed
Labels
bufferIssues and PRs related to the buffer subsystem.Issues and PRs related to the buffer subsystem.
Description
- Version: v6.7.0
- Platform: Linux 3.13.0-96-generic Ubuntu SMP x86_64 GNU/Linux
- Subsystem: NodeBuffer
It seems if one provides a non integer boundary to the slice function then the later slice calls on the same buffer provide wrong chunks.
Test case to reproduce
it("Should slice Buffer",()=>{letoriginal=newBuffer("1234567890ABCDEFG","ascii");letchunk1=original.slice(0,original.length/3);letchunk2=original.slice(original.length/3);letresult=Buffer.concat([chunk2,chunk1]);expect(result).to.be.eqls(original);});And the result is:
AssertionError: expected |Buffer 31 32 33 34 35 36 37 38 39 30 41 42 43 44 45 46| to deeply equal |Buffer 31 32 33 34 35 36 37 38 39 30 41 42 43 44 45 46 `**47**`| In this test case the result buffer misses the last byte from the original one.
I am not exactly sure what should be the correct behavior but I would be fine either with throwing an exception or round/ceil/floor the provided boundary value.
Metadata
Metadata
Assignees
Labels
bufferIssues and PRs related to the buffer subsystem.Issues and PRs related to the buffer subsystem.