Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

bytebuffer.js - this.view is never null #80

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
4 changes: 2 additions & 2 deletions src/bytebuffer.js
Original file line number Diff line number Diff line change
Expand Up @@ -51,11 +51,11 @@ var ByteBuffer = function(capacity, littleEndian, noAssert) {
this.view = capacity === 0 ? null : new DataView(this.buffer);
//? } else {
/**
* Uint8Array utilized to manipulate the backing buffer. Becomes `null` if the backing buffer has a capacity of `0`.
* Uint8Array utilized to manipulate the backing buffer.
* @type {?Uint8Array}
* @expose
*/
this.view = capacity === 0 ? null : new Uint8Array(this.buffer);
this.view = new Uint8Array(this.buffer);
//? }
//? }

Expand Down
2 changes: 1 addition & 1 deletion src/methods/compact.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ ByteBufferPrototype.compact = function(begin, end) {
if (len === 0) {
this.buffer = EMPTY_BUFFER;
//? if (!NODE)
this.view = null;
this.view = new Uint8Array(this.buffer);
if (this.markedOffset >= 0) this.markedOffset -= begin;
this.offset = 0;
this.limit = 0;
Expand Down
2 changes: 1 addition & 1 deletion tests/suite.js
Original file line number Diff line number Diff line change
Expand Up @@ -415,7 +415,7 @@ function makeSuite(ByteBuffer) {
test.notStrictEqual(bb.buffer, prevBuffer);
test.strictEqual(bb.buffer, new ByteBuffer(0).buffer); // EMPTY_BUFFER
if (type === ArrayBuffer) {
test.strictEqual(bb.view, null);
test.equal(bb.view.length, 0);
}
test.equal(bb.capacity(), 0);
test.equal(bb.offset, 0);
Expand Down