Permalink
Browse files

Use newer Buffer#write argument signature

Encoding is on the end. Backwards compatible with node >=0.8 and fixes
depreciation warnings on node 0.11.x.

Still waiting for nodejs/node-v0.x-archive#5715 to be fixed to be completely compatible with
node >0.11.2

Signed-off-by: Tim Smart <tim@fostle.com>
  • Loading branch information...
1 parent 206497b commit 9ddedc96527e814be5c3db2d99e7da10e8a98112 @tim-smart tim-smart committed Jun 19, 2013
@@ -59,8 +59,8 @@ function createMultipartBuffer(boundary, size) {
, tail = '\r\n--'+boundary+'--\r\n'
, buffer = new Buffer(size);
- buffer.write(head, 'ascii', 0);
- buffer.write(tail, 'ascii', buffer.length - tail.length);
+ buffer.write(head, 0, 'ascii');
+ buffer.write(tail, buffer.length - tail.length, 'ascii');
return buffer;
}
View
@@ -58,8 +58,8 @@ MultipartParser.stateToString = function(stateNumber) {
MultipartParser.prototype.initWithBoundary = function(str) {
this.boundary = new Buffer(str.length+4);
- this.boundary.write('\r\n--', 'ascii', 0);
- this.boundary.write(str, 'ascii', 4);
+ this.boundary.write('\r\n--', 0, 'ascii');
+ this.boundary.write(str, 4, 'ascii');
this.lookbehind = new Buffer(this.boundary.length+8);
this.state = S.START;
@@ -50,7 +50,7 @@ Object.keys(fixtures).forEach(function(name) {
endCalled = true;
};
- buffer.write(fixture.raw, 'binary', 0);
+ buffer.write(fixture.raw, 0, 'binary');
while (offset < buffer.length) {
if (offset + CHUNK_LENGTH < buffer.length) {
@@ -34,7 +34,7 @@ test(function parserError() {
buffer = new Buffer(5);
parser.initWithBoundary(boundary);
- buffer.write('--ad', 'ascii', 0);
+ buffer.write('--ad', 0, 'ascii');
assert.equal(parser.write(buffer), 5);
});

1 comment on commit 9ddedc9

bfhg17 commented on 9ddedc9 Oct 25, 2016

Thanks!

Please sign in to comment.