0
0
mirror of https://github.com/nodejs/node.git synced 2024-12-01 16:10:02 +01:00

buffer: write() should always set _charsWritten.

Fixes #1633.
This commit is contained in:
koichik 2011-09-08 11:47:32 +09:00
parent 52044fd1b1
commit 526c54c979
2 changed files with 3 additions and 0 deletions

View File

@ -122,6 +122,7 @@ SlowBuffer.prototype.hexWrite = function(string, offset, length) {
if (isNaN(byte)) throw new Error('Invalid hex string');
this[offset + i] = byte;
}
SlowBuffer._charsWritten = i * 2;
return i;
};

View File

@ -687,3 +687,5 @@ buf.write('0123456789', 'binary');
assert.equal(Buffer._charsWritten, 9);
buf.write('123456', 'base64');
assert.equal(Buffer._charsWritten, 6);
buf.write('00010203040506070809', 'hex');
assert.equal(Buffer._charsWritten, 18);