Browse Source

Add legacy methods to Buffer

v0.7.4-release
Ryan Dahl 14 years ago
parent
commit
515f006b6e
  1. 28
      lib/buffer.js

28
lib/buffer.js

@ -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");
};

Loading…
Cancel
Save