Permalink
Browse files

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 <anna@addaleax.net>
Reviewed-By: Trevor Norris <trev.norris@gmail.com>
  • Loading branch information...
jasnell committed Aug 17, 2016
1 parent 0764bc4 commit 9cee8b1b621f2803bbdd7209aea74c918081eaad
Showing with 8 additions and 0 deletions.
  1. +2 −0 lib/buffer.js
  2. +6 −0 test/parallel/test-buffer-alloc.js
@@ -1332,3 +1332,5 @@ Buffer.prototype.swap64 = function swap64() {
}
return swap64n(this);
};
Buffer.prototype.toLocaleString = Buffer.prototype.toString;
@@ -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());
}

0 comments on commit 9cee8b1

Please sign in to comment.