Add legacy methods to Buffer

This commit is contained in:
Ryan Dahl 2010-11-02 10:09:59 -07:00
parent 07812c47a4
commit 515f006b6e

View File

@ -328,3 +328,31 @@ Buffer.prototype.slice = function (start, end) {
return new Buffer(this.parent, end - start, +start + this.offset);
};
// Legacy methods for backwards compatibility.
Buffer.prototype.utf8Slice = function (start, end) {
return this.toString("utf8", start, end);
};
Buffer.prototype.binarySlice = function (start, end) {
return this.toString("binary", start, end);
};
Buffer.prototype.asciiSlice = function (start, end) {
return this.toString("ascii", start, end);
};
Buffer.prototype.utf8Write = function (string, offset) {
return this.write(string, offset, "utf8");
};
Buffer.prototype.binaryWrite = function (string, offset) {
return this.write(string, offset, "binary");
};
Buffer.prototype.asciiWrite = function (string, offset) {
return this.write(string, offset, "ascii");
};