Skip to content

Commit

Permalink
packages/firmata-io: for-of loop in encoder7bit.js, remove parseInt call
Browse files Browse the repository at this point in the history
  • Loading branch information
rwaldron committed Jan 7, 2019
1 parent 0f0e22d commit c64bd98
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions packages/firmata-io/lib/encoder7bit.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ module.exports = {
let previous = 0;
const output = [];

data.forEach(byte => {
for (let byte of data) {
if (shift === 0) {
output.push(byte & 0x7f);
shift++;
Expand All @@ -24,7 +24,7 @@ module.exports = {
previous = byte >> (8 - shift);
}
}
});
}

/* istanbul ignore else */
if (shift > 0) {
Expand All @@ -34,12 +34,12 @@ module.exports = {
return output;
},
from7BitArray(encoded) {
const expectedBytes = (encoded.length) * 7 >> 3;
const expectedBytes = encoded.length * 7 >> 3;
const decoded = [];

for (let i = 0; i < expectedBytes; i++) {
const j = i << 3;
const pos = parseInt(j / 7, 10);
const pos = (j / 7) >>> 0;
const shift = j % 7;
decoded[i] = (encoded[pos] >> shift) | ((encoded[pos + 1] << (7 - shift)) & 0xFF);
}
Expand Down

0 comments on commit c64bd98

Please sign in to comment.