diff --git a/lib/buffer.js b/lib/buffer.js index e40b81a693c9fd..84f63a57df42c9 100644 --- a/lib/buffer.js +++ b/lib/buffer.js @@ -1332,3 +1332,5 @@ Buffer.prototype.swap64 = function swap64() { } return swap64n(this); }; + +Buffer.prototype.toLocaleString = Buffer.prototype.toString; diff --git a/test/parallel/test-buffer-alloc.js b/test/parallel/test-buffer-alloc.js index 00b63848d4e2d4..57bc8715974032 100644 --- a/test/parallel/test-buffer-alloc.js +++ b/test/parallel/test-buffer-alloc.js @@ -1502,3 +1502,9 @@ assert.throws(() => Buffer.alloc({ valueOf: () => 1 }), /"size" argument must be a number/); assert.throws(() => Buffer.alloc({ valueOf: () => -1 }), /"size" argument must be a number/); + +assert.strictEqual(Buffer.prototype.toLocaleString, Buffer.prototype.toString); +{ + const buf = Buffer.from('test'); + assert.strictEqual(buf.toLocaleString(), buf.toString()); +}