Skip to content

Commit 885186b

Browse files
committed
Fix check for Long in readVarint64
1 parent 57f7e7b commit 885186b

9 files changed

+28
-26
lines changed

bower.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "bytebuffer",
3-
"version": "3.0.0-RC1",
3+
"version": "3.0.0-RC2",
44
"author": "Daniel Wirtz <[email protected]>",
55
"description": "A full-featured ByteBuffer implementation using typed arrays.",
66
"main": "ByteBuffer.js",

dist/ByteBufferAB.js

+2-2
Original file line numberDiff line numberDiff line change
@@ -117,7 +117,7 @@
117117
* @const
118118
* @expose
119119
*/
120-
ByteBuffer.VERSION = "3.0.0-RC1";
120+
ByteBuffer.VERSION = "3.0.0-RC2";
121121

122122
/**
123123
* Little endian constant that can be used instead of its boolean value. Evaluates to `true`.
@@ -1352,7 +1352,7 @@
13521352
*/
13531353
ByteBuffer.prototype.readVarint64ZigZag = function(offset) {
13541354
var val = this.readVarint64(offset);
1355-
if (typeof val === 'object')
1355+
if (val && val['value'] instanceof Long)
13561356
val["value"] = ByteBuffer.zigZagDecode64(val["value"]);
13571357
else
13581358
val = ByteBuffer.zigZagDecode64(val);

dist/ByteBufferAB.min.js

+4-4
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

dist/ByteBufferAB.min.js.gz

17 Bytes
Binary file not shown.

dist/ByteBufferAB.min.map

+1-1
Large diffs are not rendered by default.

dist/ByteBufferNB.js

+2-2
Original file line numberDiff line numberDiff line change
@@ -109,7 +109,7 @@ module.exports = (function() {
109109
* @const
110110
* @expose
111111
*/
112-
ByteBuffer.VERSION = "3.0.0-RC1";
112+
ByteBuffer.VERSION = "3.0.0-RC2";
113113

114114
/**
115115
* Little endian constant that can be used instead of its boolean value. Evaluates to `true`.
@@ -1508,7 +1508,7 @@ module.exports = (function() {
15081508
*/
15091509
ByteBuffer.prototype.readVarint64ZigZag = function(offset) {
15101510
var val = this.readVarint64(offset);
1511-
if (typeof val === 'object')
1511+
if (val && val['value'] instanceof Long)
15121512
val["value"] = ByteBuffer.zigZagDecode64(val["value"]);
15131513
else
15141514
val = ByteBuffer.zigZagDecode64(val);

package.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "bytebuffer",
3-
"version": "3.0.0-RC1",
3+
"version": "3.0.0-RC2",
44
"author": "Daniel Wirtz <[email protected]>",
55
"description": "The swiss army knife for binary data in JavaScript.",
66
"main": "ByteBuffer.js",

src/types/varints/varint64.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -210,7 +210,7 @@ if (Long) {
210210
*/
211211
ByteBuffer.prototype.readVarint64ZigZag = function(offset) {
212212
var val = this.readVarint64(offset);
213-
if (typeof val === 'object')
213+
if (val && val['value'] instanceof Long)
214214
val["value"] = ByteBuffer.zigZagDecode64(val["value"]);
215215
else
216216
val = ByteBuffer.zigZagDecode64(val);

tests/suite.js

+16-14
Original file line numberDiff line numberDiff line change
@@ -513,21 +513,23 @@ function makeSuite(ByteBuffer) {
513513
};
514514

515515
var types = [
516-
// name | alias | size | input | output | BE representation
517-
["Int8" , "Byte" , 1 , 0xFE , -2 , "fe" ],
518-
["Uint8" , null , 1 , -2 , 0xFE , "fe" ],
519-
["Int16" , "Short" , 2 , 0xFFFE , -2 , "fffe" ],
520-
["Uint16" , null , 2 , -2 , 0xFFFE , "fffe" ],
521-
["Int32" , "Int" , 4 , 0xFFFFFFFE , -2 , "fffffffe" ],
522-
["Uint32" , null , 4 , -2 , 0xFFFFFFFE , "fffffffe" ],
523-
["Float32" , "Float" , 4 , 0.5 , 0.5 , "3f000000" ],
524-
["Float64" , "Double", 8 , 0.1 , 0.1 , "3fb999999999999a" ],
525-
["Int64" , "Long" , 8 , new Long(0xFFFFFFFE, 0xFFFFFFFF, true) , new Long(0xFFFFFFFE, 0xFFFFFFFF, false) , "fffffffffffffffe" ],
526-
["Uint64" , null , 8 , new Long(0xFFFFFFFE, 0xFFFFFFFF, false) , new Long(0xFFFFFFFE, 0xFFFFFFFF, true) , "fffffffffffffffe" ],
516+
// name | alias | size | input | output | BE representation
517+
["Int8" , "Byte" , 1 , 0xFE , -2 , "fe" ],
518+
["Uint8" , null , 1 , -2 , 0xFE , "fe" ],
519+
["Int16" , "Short" , 2 , 0xFFFE , -2 , "fffe" ],
520+
["Uint16" , null , 2 , -2 , 0xFFFE , "fffe" ],
521+
["Int32" , "Int" , 4 , 0xFFFFFFFE , -2 , "fffffffe" ],
522+
["Uint32" , null , 4 , -2 , 0xFFFFFFFE , "fffffffe" ],
523+
["Float32" , "Float" , 4 , 0.5 , 0.5 , "3f000000" ],
524+
["Float64" , "Double", 8 , 0.1 , 0.1 , "3fb999999999999a" ],
525+
["Int64" , "Long" , 8 , new Long(0xFFFFFFFE, 0xFFFFFFFF, true) , new Long(0xFFFFFFFE, 0xFFFFFFFF, false) , "fffffffffffffffe" ],
526+
["Uint64" , null , 8 , new Long(0xFFFFFFFE, 0xFFFFFFFF, false) , new Long(0xFFFFFFFE, 0xFFFFFFFF, true) , "fffffffffffffffe" ],
527527

528-
// name | alias | size | input | output | representation
529-
["Varint32", null , 5 , 0xFFFFFFFE , -2 , "feffffff0f" ],
530-
["Varint64", null , 10 , new Long(0xFFFFFFFE, 0xFFFFFFFF, true) , new Long(0xFFFFFFFE, 0xFFFFFFFF, false) , "feffffffffffffffff01"]
528+
// name | alias | size | input | output | representation
529+
["Varint32" , null , 5 , 0xFFFFFFFE , -2 , "feffffff0f" ],
530+
["Varint32ZigZag", null , 1 , -1 , -1 , "01" ],
531+
["Varint64" , null , 10 , new Long(0xFFFFFFFE, 0xFFFFFFFF, true) , new Long(0xFFFFFFFE, 0xFFFFFFFF, false) , "feffffffffffffffff01"],
532+
["Varint64ZigZag", null , 1 , Long.fromNumber(-1) , Long.fromNumber(-1) , "01" ]
531533
];
532534

533535
suite.types = {};

0 commit comments

Comments
 (0)