mirror of
https://github.com/nodejs/node.git
synced 2024-12-01 16:10:02 +01:00
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>
This commit is contained in:
parent
797ec338ea
commit
1e21d05632
@ -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…
Reference in New Issue
Block a user