Skip to content

Commit ff1fce6

Browse files
committed
Fix that
1 parent 0f4b055 commit ff1fce6

File tree

7 files changed

+27
-9
lines changed

7 files changed

+27
-9
lines changed

ByteBuffer.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2025,7 +2025,7 @@
20252025
* @expose
20262026
*/
20272027
ByteBuffer.prototype.toBase64 = function() {
2028-
if (this.array == null || this.offset < this.length) return "";
2028+
if (this.array == null || this.offset >= this.length) return "";
20292029
return ByteBuffer.encode64(this);
20302030
};
20312031

@@ -2035,7 +2035,7 @@
20352035
* @expose
20362036
*/
20372037
ByteBuffer.prototype.toUTF8 = function() {
2038-
if (this.array == null || this.offset < this.length) return "";
2038+
if (this.array == null || this.offset >= this.length) return "";
20392039
return this.readUTF8StringBytes(this.length - this.offset, this.offset).string;
20402040
};
20412041

ByteBuffer.min.js

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

ByteBuffer.min.map

Lines changed: 1 addition & 1 deletion
Large diffs are not rendered by default.

ByteBuffer.noexpose.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1922,7 +1922,7 @@
19221922
* @returns {string} Base 64 encoded string
19231923
*/
19241924
ByteBuffer.prototype.toBase64 = function() {
1925-
if (this.array == null || this.offset < this.length) return "";
1925+
if (this.array == null || this.offset >= this.length) return "";
19261926
return ByteBuffer.encode64(this);
19271927
};
19281928

@@ -1931,7 +1931,7 @@
19311931
* @returns {string}
19321932
*/
19331933
ByteBuffer.prototype.toUTF8 = function() {
1934-
if (this.array == null || this.offset < this.length) return "";
1934+
if (this.array == null || this.offset >= this.length) return "";
19351935
return this.readUTF8StringBytes(this.length - this.offset, this.offset).string;
19361936
};
19371937

externs/ByteBuffer.js

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -762,6 +762,22 @@ ByteBuffer.zigZagEncode32 = function(n) {};
762762
*/
763763
ByteBuffer.zigZagDecode32 = function(n) {};
764764

765+
/**
766+
* @param {ByteBuffer} bb
767+
* @return {string}
768+
* @throws {Error}
769+
* @nosideeffects
770+
*/
771+
ByteBuffer.encode64 = function(bb) {};
772+
773+
/**
774+
* @param {string} str
775+
* @return {!ByteBuffer}
776+
* @throws {Error}
777+
* @nosideeffects
778+
*/
779+
ByteBuffer.decode64 = function(str) {};
780+
765781
/**
766782
* @type {number}
767783
* @const

src/ByteBuffer.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2025,7 +2025,7 @@
20252025
* @expose
20262026
*/
20272027
ByteBuffer.prototype.toBase64 = function() {
2028-
if (this.array == null || this.offset < this.length) return "";
2028+
if (this.array == null || this.offset >= this.length) return "";
20292029
return ByteBuffer.encode64(this);
20302030
};
20312031

@@ -2035,7 +2035,7 @@
20352035
* @expose
20362036
*/
20372037
ByteBuffer.prototype.toUTF8 = function() {
2038-
if (this.array == null || this.offset < this.length) return "";
2038+
if (this.array == null || this.offset >= this.length) return "";
20392039
return this.readUTF8StringBytes(this.length - this.offset, this.offset).string;
20402040
};
20412041

tests/suite.js

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@
2323
* File to use.
2424
* @type {string}
2525
*/
26-
var FILE = "ByteBuffer.js";
26+
var FILE = "ByteBuffer.min.js";
2727

2828
/**
2929
* ByteBuffer.
@@ -769,6 +769,8 @@ var suite = {
769769
var bb = ByteBuffer.decode64(b64);
770770
test.strictEqual(bb.readUTF8String(str.length, 0).string, str);
771771
test.strictEqual(ByteBuffer.encode64(bb), b64);
772+
test.strictEqual(bb.toBase64(), b64);
773+
test.strictEqual(bb.toString("base64"), b64);
772774
}
773775
test.done();
774776
},

0 commit comments

Comments
 (0)