Skip to content

Commit

Permalink
buffer: alias toLocaleString to toString
Browse files Browse the repository at this point in the history
Make Buffer.prototype.toLocaleString an alias of Buffer.prototype.toString
so that the output is actually useful.

Fixes: nodejs#8147
  • Loading branch information
jasnell committed Aug 17, 2016
1 parent b417087 commit e9951ce
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 0 deletions.
2 changes: 2 additions & 0 deletions lib/buffer.js
Original file line number Diff line number Diff line change
Expand Up @@ -1332,3 +1332,5 @@ Buffer.prototype.swap64 = function swap64() {
}
return swap64n(this);
};

Buffer.prototype.toLocaleString = Buffer.prototype.toString;
6 changes: 6 additions & 0 deletions test/parallel/test-buffer-alloc.js
Original file line number Diff line number Diff line change
Expand Up @@ -1496,3 +1496,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 e9951ce

Please sign in to comment.