1
0
Fork 0
mirror of https://github.com/codedread/bitjs synced 2025-10-03 17:49:16 +02:00

Start the move to es6: Change all vars to lets/consts

This commit is contained in:
codedread 2017-02-20 12:47:17 -08:00
parent 87cdd92981
commit 639a23e69b
11 changed files with 514 additions and 555 deletions

View file

@ -67,9 +67,9 @@ bitjs.io.ByteBuffer.prototype.writeNumber = function(num, numBytes) {
}
// Roll 8-bits at a time into an array of bytes.
var bytes = [];
const bytes = [];
while (numBytes-- > 0) {
var eightBits = num & 255;
const eightBits = num & 255;
bytes.push(eightBits);
num >>= 8;
}
@ -89,15 +89,15 @@ bitjs.io.ByteBuffer.prototype.writeSignedNumber = function(num, numBytes) {
throw 'Trying to write into too few bytes: ' + numBytes;
}
var HALF = Math.pow(2, (numBytes * 8) - 1);
const HALF = Math.pow(2, (numBytes * 8) - 1);
if (num >= HALF || num < -HALF) {
throw 'Trying to write ' + num + ' into only ' + numBytes + ' bytes';
}
// Roll 8-bits at a time into an array of bytes.
var bytes = [];
const bytes = [];
while (numBytes-- > 0) {
var eightBits = num & 255;
const eightBits = num & 255;
bytes.push(eightBits);
num >>= 8;
}
@ -110,8 +110,8 @@ bitjs.io.ByteBuffer.prototype.writeSignedNumber = function(num, numBytes) {
* @param {string} str The ASCII string to write.
*/
bitjs.io.ByteBuffer.prototype.writeASCIIString = function(str) {
for (var i = 0; i < str.length; ++i) {
var curByte = str.charCodeAt(i);
for (let i = 0; i < str.length; ++i) {
const curByte = str.charCodeAt(i);
if (curByte < 0 || curByte > 255) {
throw 'Trying to write a non-ASCII string!';
}