Change Buffer toString() output
This commit is contained in:
parent
3546106c43
commit
6740dd48b3
@ -2,19 +2,23 @@ var Buffer = process.binding('buffer').Buffer;
|
|||||||
|
|
||||||
exports.Buffer = Buffer;
|
exports.Buffer = Buffer;
|
||||||
|
|
||||||
|
function toHex (n) {
|
||||||
|
if (n < 16) return "0" + n.toString(16);
|
||||||
|
return n.toString(16);
|
||||||
|
}
|
||||||
|
|
||||||
Buffer.prototype.toString = function () {
|
Buffer.prototype.toString = function () {
|
||||||
return this.utf8Slice(0, this.length);
|
var s = "<Buffer ";
|
||||||
|
for (var i = 0; i < this.length; i++) {
|
||||||
|
s += toHex(this[i]);
|
||||||
|
if (i != this.length - 1) s += ' ';
|
||||||
|
}
|
||||||
|
s += ">";
|
||||||
|
return s;
|
||||||
};
|
};
|
||||||
|
|
||||||
Buffer.prototype.toJSON = function () {
|
Buffer.prototype.toJSON = function () {
|
||||||
return this.utf8Slice(0, this.length);
|
return this.utf8Slice(0, this.length);
|
||||||
/*
|
|
||||||
var s = "";
|
|
||||||
for (var i = 0; i < this.length; i++) {
|
|
||||||
s += this[i].toString(16) + " ";
|
|
||||||
}
|
|
||||||
return s;
|
|
||||||
*/
|
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user