Browse Source

buffer: avoid use of arguments

Avoid use of arguments in Buffer.prototype.toString()

PR-URL: https://github.com/nodejs/node/pull/11358
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
Reviewed-By: Сковорода Никита Андреевич <chalkerx@gmail.com>
Reviewed-By: Luigi Pinca <luigipinca@gmail.com>
Reviewed-By: Joyee Cheung <joyeec9h3@gmail.com>
Reviewed-By: Anna Henningsen <anna@addaleax.net>
v6
James M Snell 8 years ago
parent
commit
1e21d05632
  1. 4
      lib/buffer.js

4
lib/buffer.js

@ -503,12 +503,12 @@ Buffer.prototype.copy = function(target, targetStart, sourceStart, sourceEnd) {
return binding.copy(this, target, targetStart, sourceStart, sourceEnd);
};
Buffer.prototype.toString = function() {
Buffer.prototype.toString = function(encoding, start, end) {
let result;
if (arguments.length === 0) {
result = this.utf8Slice(0, this.length);
} else {
result = slowToString.apply(this, arguments);
result = slowToString.call(this, encoding, start, end);
}
if (result === undefined)
throw new Error('"toString()" failed');

Loading…
Cancel
Save