map charsWritten to fast buffer
This commit is contained in:
parent
ececd92f62
commit
5506f99dfa
@ -211,23 +211,33 @@ Buffer.prototype.write = function write (string, offset, encoding) {
|
|||||||
// Make sure we are not going to overflow
|
// Make sure we are not going to overflow
|
||||||
var maxLength = this.length - offset;
|
var maxLength = this.length - offset;
|
||||||
|
|
||||||
|
var ret;
|
||||||
switch (encoding) {
|
switch (encoding) {
|
||||||
case 'utf8':
|
case 'utf8':
|
||||||
case 'utf-8':
|
case 'utf-8':
|
||||||
return this.parent.utf8Write(string, this.offset + offset, maxLength);
|
ret = this.parent.utf8Write(string, this.offset + offset, maxLength);
|
||||||
|
break;
|
||||||
|
|
||||||
case 'ascii':
|
case 'ascii':
|
||||||
return this.parent.asciiWrite(string, this.offset + offset, maxLength);
|
ret = this.parent.asciiWrite(string, this.offset + offset, maxLength);
|
||||||
|
break;
|
||||||
|
|
||||||
case 'binary':
|
case 'binary':
|
||||||
return this.parent.binaryWrite(string, this.offset + offset, maxLength);
|
ret = this.parent.binaryWrite(string, this.offset + offset, maxLength);
|
||||||
|
break;
|
||||||
|
|
||||||
case 'base64':
|
case 'base64':
|
||||||
return this.parent.base64Write(string, this.offset + offset, maxLength);
|
// Warning: maxLength not taken into account in base64Write
|
||||||
|
ret = this.parent.base64Write(string, this.offset + offset, maxLength);
|
||||||
|
break;
|
||||||
|
|
||||||
default:
|
default:
|
||||||
throw new Error('Unknown encoding');
|
throw new Error('Unknown encoding');
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Buffer._charsWritten = SlowBuffer._charsWritten;
|
||||||
|
|
||||||
|
return ret;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user