Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Buffer integer writing functions return (offset + number bytes written) instead of (number bytes written) #5846

Closed
quentinadam opened this issue Mar 22, 2016 · 1 comment

Comments

@quentinadam
Copy link

  • Version: 5.9.0
  • Platform: Mac OS X 10.11.3 64-bit (Darwin Kernel Version 15.3.0)

When using the convenience methods to write integers to Buffer objects (like for example buf.writeUInt32LE(value, offset[, noAssert])), the value returned is (offset + number bytes written) instead of (number bytes written) as is indicated in the documentation.

Test case :

var buf = new Buffer(100);
var value = 1;
var offset = 20;
console.log(buf.writeUInt32LE(value, offset)); //outputs 24 instead of 4

This issue seems to appear with all integer writing functions.

@jasnell
Copy link
Member

jasnell commented Mar 22, 2016

Yep, the documentation is wrong and has been fixed in master. See: #5736

@jasnell jasnell closed this as completed Mar 22, 2016
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants