Skip to content

Commit 9cee8b1

Browse files
committed
buffer: alias toLocaleString to toString
Make Buffer.prototype.toLocaleString an alias of Buffer.prototype.toString so that the output is actually useful. Fixes: #8147 PR-URL: #8148 Reviewed-By: Anna Henningsen <[email protected]> Reviewed-By: Trevor Norris <[email protected]>
1 parent 0764bc4 commit 9cee8b1

File tree

2 files changed

+8
-0
lines changed

2 files changed

+8
-0
lines changed

lib/buffer.js

+2
Original file line numberDiff line numberDiff line change
@@ -1332,3 +1332,5 @@ Buffer.prototype.swap64 = function swap64() {
13321332
}
13331333
return swap64n(this);
13341334
};
1335+
1336+
Buffer.prototype.toLocaleString = Buffer.prototype.toString;

test/parallel/test-buffer-alloc.js

+6
Original file line numberDiff line numberDiff line change
@@ -1502,3 +1502,9 @@ assert.throws(() => Buffer.alloc({ valueOf: () => 1 }),
15021502
/"size" argument must be a number/);
15031503
assert.throws(() => Buffer.alloc({ valueOf: () => -1 }),
15041504
/"size" argument must be a number/);
1505+
1506+
assert.strictEqual(Buffer.prototype.toLocaleString, Buffer.prototype.toString);
1507+
{
1508+
const buf = Buffer.from('test');
1509+
assert.strictEqual(buf.toLocaleString(), buf.toString());
1510+
}

0 commit comments

Comments
 (0)