|
|
@ -22,6 +22,15 @@ |
|
|
|
var SlowBuffer = process.binding('buffer').SlowBuffer; |
|
|
|
var assert = require('assert'); |
|
|
|
|
|
|
|
// Deprecate the 'binary' encoding.
|
|
|
|
// TODO: Remove it entirely in v0.9.
|
|
|
|
var binaryWarned = false; |
|
|
|
function binaryWarn() { |
|
|
|
if (binaryWarned) return; |
|
|
|
binaryWarned = true; |
|
|
|
console.error('The binary buffer encoding is deprecated.'); |
|
|
|
} |
|
|
|
|
|
|
|
exports.INSPECT_MAX_BYTES = 50; |
|
|
|
|
|
|
|
|
|
|
@ -82,6 +91,7 @@ SlowBuffer.prototype.toString = function(encoding, start, end) { |
|
|
|
return this.asciiSlice(start, end); |
|
|
|
|
|
|
|
case 'binary': |
|
|
|
binaryWarn(); |
|
|
|
return this.binarySlice(start, end); |
|
|
|
|
|
|
|
case 'base64': |
|
|
@ -168,6 +178,7 @@ SlowBuffer.prototype.write = function(string, offset, length, encoding) { |
|
|
|
return this.asciiWrite(string, offset, length); |
|
|
|
|
|
|
|
case 'binary': |
|
|
|
binaryWarn(); |
|
|
|
return this.binaryWrite(string, offset, length); |
|
|
|
|
|
|
|
case 'base64': |
|
|
@ -368,6 +379,7 @@ Buffer.prototype.write = function(string, offset, length, encoding) { |
|
|
|
break; |
|
|
|
|
|
|
|
case 'binary': |
|
|
|
binaryWarn(); |
|
|
|
ret = this.parent.binaryWrite(string, this.offset + offset, length); |
|
|
|
break; |
|
|
|
|
|
|
@ -424,6 +436,7 @@ Buffer.prototype.toString = function(encoding, start, end) { |
|
|
|
return this.parent.asciiSlice(start, end); |
|
|
|
|
|
|
|
case 'binary': |
|
|
|
binaryWarn(); |
|
|
|
return this.parent.binarySlice(start, end); |
|
|
|
|
|
|
|
case 'base64': |
|
|
@ -536,6 +549,7 @@ Buffer.prototype.utf8Slice = function(start, end) { |
|
|
|
}; |
|
|
|
|
|
|
|
Buffer.prototype.binarySlice = function(start, end) { |
|
|
|
binaryWarn(); |
|
|
|
return this.toString('binary', start, end); |
|
|
|
}; |
|
|
|
|
|
|
@ -548,6 +562,7 @@ Buffer.prototype.utf8Write = function(string, offset) { |
|
|
|
}; |
|
|
|
|
|
|
|
Buffer.prototype.binaryWrite = function(string, offset) { |
|
|
|
binaryWarn(); |
|
|
|
return this.write(string, offset, 'binary'); |
|
|
|
}; |
|
|
|
|
|
|
|