Skip to content

Commit 03fd504

Browse files
committed
Fixed indentation.
1 parent 511102c commit 03fd504

File tree

2 files changed

+37
-37
lines changed

2 files changed

+37
-37
lines changed

src/jparser.js

+24-24
Original file line numberDiff line numberDiff line change
@@ -81,7 +81,7 @@ jParser.prototype.structure = {
8181
bitfield: function (structure, bitShift) {
8282
var output = {};
8383

84-
bitShift = bitShift || 0;
84+
bitShift = bitShift || 0;
8585

8686
for (var key in structure) {
8787
var fieldInfo = structure[key],
@@ -90,29 +90,29 @@ jParser.prototype.structure = {
9090
if (typeof fieldInfo === 'object') {
9191
fieldValue = this.parse(this.structure.bitfield, fieldInfo, bitShift);
9292
} else {
93-
this.current = output;
94-
95-
var bitSize = toInt.call(this, fieldInfo);
96-
fieldValue = 0;
97-
98-
if (bitShift < 0) {
99-
var byteShift = bitShift >> 3; // Math.floor(bitShift / 8)
100-
this.skip(byteShift);
101-
bitShift &= 7; // bitShift + 8 * Math.floor(bitShift / 8)
102-
}
103-
if (bitShift > 0 && bitSize >= 8 - bitShift) {
104-
fieldValue = this.view.getUint8() & ~(-1 << (8 - bitShift));
105-
bitSize -= 8 - bitShift;
106-
bitShift = 0;
107-
}
108-
while (bitSize >= 8) {
109-
fieldValue = this.view.getUint8() | (fieldValue << 8);
110-
bitSize -= 8;
111-
}
112-
if (bitSize > 0) {
113-
fieldValue = ((this.view.getUint8() >>> (8 - (bitShift + bitSize))) & ~(-1 << bitSize)) | (fieldValue << bitSize);
114-
bitShift = bitShift + bitSize - 8; // passing negative value for next pass
115-
}
93+
this.current = output;
94+
95+
var bitSize = toInt.call(this, fieldInfo);
96+
fieldValue = 0;
97+
98+
if (bitShift < 0) {
99+
var byteShift = bitShift >> 3; // Math.floor(bitShift / 8)
100+
this.skip(byteShift);
101+
bitShift &= 7; // bitShift + 8 * Math.floor(bitShift / 8)
102+
}
103+
if (bitShift > 0 && bitSize >= 8 - bitShift) {
104+
fieldValue = this.view.getUint8() & ~(-1 << (8 - bitShift));
105+
bitSize -= 8 - bitShift;
106+
bitShift = 0;
107+
}
108+
while (bitSize >= 8) {
109+
fieldValue = this.view.getUint8() | (fieldValue << 8);
110+
bitSize -= 8;
111+
}
112+
if (bitSize > 0) {
113+
fieldValue = ((this.view.getUint8() >>> (8 - (bitShift + bitSize))) & ~(-1 << bitSize)) | (fieldValue << bitSize);
114+
bitShift = bitShift + bitSize - 8; // passing negative value for next pass
115+
}
116116
}
117117

118118
output[key] = fieldValue;

test/test.js

+13-13
Original file line numberDiff line numberDiff line change
@@ -86,19 +86,19 @@ test('bitfield', function () {
8686
var bitfield = parser.parse(['bitfield', {
8787
first5: 5,
8888
next5: function () {
89-
return 5;
90-
},
89+
return 5;
90+
},
9191
last6: {
92-
first3: 3,
93-
last3: 3
94-
}
92+
first3: 3,
93+
last3: 3
94+
}
9595
}]);
96-
deepEqual(bitfield, {
97-
first5: 0x17,
98-
next5: 0x08,
99-
last6: {
100-
first3: 0,
101-
last3: 1
102-
}
103-
});
96+
deepEqual(bitfield, {
97+
first5: 0x17,
98+
next5: 0x08,
99+
last6: {
100+
first3: 0,
101+
last3: 1
102+
}
103+
});
104104
})

0 commit comments

Comments
 (0)