Skip to content

Commit 569fe9d

Browse files
committed
feat: add toLocaleString method.
1 parent 76641b2 commit 569fe9d

File tree

2 files changed

+13
-2
lines changed

2 files changed

+13
-2
lines changed

src/dynamicBuffer.ts

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -840,6 +840,15 @@ export class DynamicBuffer {
840840
};
841841
}
842842

843+
/**
844+
* The alias of toString().
845+
*
846+
* @returns The string decodes from buffer
847+
*/
848+
toLocaleString() {
849+
return this.toString();
850+
}
851+
843852
/**
844853
* Decodes buffer to a string with the specified character encoding and range.
845854
*

test/export.spec.ts

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,7 @@ describe('Export string tests', () => {
4848
const buffer = new DynamicBuffer();
4949

5050
assert.equal(buffer.toString(), '');
51+
assert.equal(buffer.toLocaleString(), '');
5152
});
5253

5354
it('Test toString() without parameters', () => {
@@ -56,6 +57,7 @@ describe('Export string tests', () => {
5657
buffer.append('Hello world');
5758

5859
assert.equal(buffer.toString(), 'Hello world');
60+
assert.equal(buffer.toLocaleString(), 'Hello world');
5961
});
6062

6163
it('Test toString() with start parameter only', () => {
@@ -71,15 +73,15 @@ describe('Export string tests', () => {
7173

7274
buffer.append('Hello world');
7375

74-
assert.equal(buffer.toString('utf8', 20).toString(), '');
76+
assert.equal(buffer.toString('utf8', 20), '');
7577
});
7678

7779
it('Test toString() with large end parameter', () => {
7880
const buffer = new DynamicBuffer();
7981

8082
buffer.append('Hello world');
8183

82-
assert.equal(buffer.toString('utf8', 0, 100).toString(), 'Hello world');
84+
assert.equal(buffer.toString('utf8', 0, 100), 'Hello world');
8385
});
8486

8587
it('Test toString() with same start and end parameters', () => {

0 commit comments

Comments
 (0)