Skip to content

Commit b1a5cc2

Browse files
committed
Fix lint errors
1 parent 6847d69 commit b1a5cc2

File tree

1 file changed

+12
-10
lines changed

1 file changed

+12
-10
lines changed

bit-buffer.js

Lines changed: 12 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -64,19 +64,20 @@ BitView.prototype.getBits = function (offset, bits, signed) {
6464
// the max number of bits we can read from the current byte
6565
var read = Math.min(remaining, 8 - bitOffset);
6666

67+
var mask, readBits;
6768
if (this.bigEndian) {
6869
// create a mask with the correct bit width
69-
var mask = ~(0xFF << read);
70+
mask = ~(0xFF << read);
7071
// shift the bits we want to the start of the byte and mask of the rest
71-
var readBits = (currentByte >> (8 - read - bitOffset)) & mask;
72+
readBits = (currentByte >> (8 - read - bitOffset)) & mask;
7273

7374
value <<= read;
7475
value |= readBits;
7576
} else {
7677
// create a mask with the correct bit width
77-
var mask = ~(0xFF << read);
78+
mask = ~(0xFF << read);
7879
// shift the bits we want to the start of the byte and mask off the rest
79-
var readBits = (currentByte >> bitOffset) & mask;
80+
readBits = (currentByte >> bitOffset) & mask;
8081

8182
value |= readBits << i;
8283
}
@@ -112,29 +113,30 @@ BitView.prototype.setBits = function (offset, value, bits) {
112113
var byteOffset = offset >> 3;
113114
var wrote = Math.min(remaining, 8 - bitOffset);
114115

116+
var mask, writeBits, destMask;
115117
if (this.bigEndian) {
116118
// create a mask with the correct bit width
117-
var mask = ~(~0 << wrote);
119+
mask = ~(~0 << wrote);
118120
// shift the bits we want to the start of the byte and mask of the rest
119-
var writeBits = (value >> (bits - i - wrote)) & mask;
121+
writeBits = (value >> (bits - i - wrote)) & mask;
120122

121123
var destShift = 8 - bitOffset - wrote;
122124
// destination mask to zero all the bits we're changing first
123-
var destMask = ~(mask << destShift);
125+
destMask = ~(mask << destShift);
124126

125127
this._view[byteOffset] =
126128
(this._view[byteOffset] & destMask)
127129
| (writeBits << destShift);
128130

129131
} else {
130132
// create a mask with the correct bit width
131-
var mask = ~(0xFF << wrote);
133+
mask = ~(0xFF << wrote);
132134
// shift the bits we want to the start of the byte and mask of the rest
133-
var writeBits = value & mask;
135+
writeBits = value & mask;
134136
value >>= wrote;
135137

136138
// destination mask to zero all the bits we're changing first
137-
var destMask = ~(mask << bitOffset);
139+
destMask = ~(mask << bitOffset);
138140

139141
this._view[byteOffset] =
140142
(this._view[byteOffset] & destMask)

0 commit comments

Comments
 (0)