Skip to content

Commit a65b4ae

Browse files
committed
Merge pull request #43 from oskarhane/1.0-32-support
Define readUInt32 on buffer
2 parents ad47e45 + 8ecddbf commit a65b4ae

File tree

2 files changed

+9
-0
lines changed

2 files changed

+9
-0
lines changed

src/v1/internal/buf.js

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -199,6 +199,13 @@ class BaseBuffer
199199
return this.getUInt16( this._updatePos(2) );
200200
}
201201

202+
/**
203+
* Read from state position.
204+
*/
205+
readUInt32 () {
206+
return this.getUInt32( this._updatePos(4) );
207+
}
208+
202209
/**
203210
* Read from state position.
204211
*/

test/internal/packstream.test.js

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,8 @@ describe('packstream', function() {
4747
it('should pack strings', function() {
4848
expect( packAndUnpack( "" ) ).toBe( "" );
4949
expect( packAndUnpack( "abcdefg123567" ) ).toBe( "abcdefg123567" );
50+
var str = Array(65536 + 1).join('a'); // 2 ^ 16 + 1
51+
expect( packAndUnpack(str, str.length + 8)).toBe(str);
5052
});
5153
it('should pack structures', function() {
5254
expect( packAndUnpack( new Structure(1, ["Hello, world!!!"] ) ).fields[0] )

0 commit comments

Comments
 (0)