Skip to content
This repository has been archived by the owner on Dec 2, 2022. It is now read-only.

Commit

Permalink
some lets can be const
Browse files Browse the repository at this point in the history
  • Loading branch information
incognitojam committed Mar 17, 2022
1 parent 05c6bb0 commit 64b35e3
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 19 deletions.
4 changes: 2 additions & 2 deletions src/impl/node.js
Original file line number Diff line number Diff line change
Expand Up @@ -148,12 +148,12 @@ export default class Panda {
}
});
if (!endpoint) {
let err = new Error('PandaJS: nodeusb: transferIn failed to find endpoint interface ' + endpointNumber);
const err = new Error('PandaJS: nodeusb: transferIn failed to find endpoint interface ' + endpointNumber);
ErrorEvent.broadcast(this, err);
return reject(err);
}
if (endpoint.direction !== 'in') {
let err = new Error('PandaJS: nodeusb: endpoint interface is ' + endpoint.direction + ' instead of in');
const err = new Error('PandaJS: nodeusb: endpoint interface is ' + endpoint.direction + ' instead of in');
ErrorEvent.broadcast(this, err);
return reject(err);
}
Expand Down
8 changes: 4 additions & 4 deletions src/panda-device.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,20 +3,20 @@ export default function PandaUSB (options) {
if (options.wifi) {
throw new Error('You cannot use wifi mode in the browser.');
}
let PandaWebUSB = require('./impl/browser').default;
const PandaWebUSB = require('./impl/browser').default;
return new PandaWebUSB(options, navigator.usb);
}
if (options.wifi) {
let PandaWifi = require('./impl/wifi').default;
const PandaWifi = require('./impl/wifi').default;
return new PandaWifi(options);
}
// check for test before node since tests always run in node
if (isTestEnv()) {
let PandaMock = require('./impl/mock').default;
const PandaMock = require('./impl/mock').default;
return new PandaMock(options);
}
if (require('is-node')) {
let PandaNodeUSB = require('./impl/node').default;
const PandaNodeUSB = require('./impl/node').default;
return new PandaNodeUSB(options);
}
console.log(process.env);
Expand Down
26 changes: 13 additions & 13 deletions src/panda.js
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@ export default class Panda {

// vendor API methods
async getHealth() {
let buf = await this.vendorRequest('health', {
const buf = await this.vendorRequest('health', {
request: 0xd2,
value: 0,
index: 0
Expand All @@ -116,15 +116,15 @@ export default class Panda {
};
}
async getDeviceMetadata() {
let buf = await this.vendorRequest('getDeviceMetadata', {
const buf = await this.vendorRequest('getDeviceMetadata', {
request: 0xd0,
value: 0,
index: 0
}, 0x20);

let serial = buf.slice(0, 0x10); // serial is the wifi style serial
let secret = buf.slice(0x10, 0x10 + 10);
let hashSig = buf.slice(0x1c);
const serial = buf.slice(0, 0x10); // serial is the wifi style serial
const secret = buf.slice(0x10, 0x10 + 10);
const hashSig = buf.slice(0x1c);

return [serial.toString(), secret.toString()];
}
Expand All @@ -137,7 +137,7 @@ export default class Panda {
return secret;
}
async getVersion() {
let buf = await this.vendorRequest('getVersion', {
const buf = await this.vendorRequest('getVersion', {
request: 0xd6,
value: 0,
index: 0
Expand All @@ -146,7 +146,7 @@ export default class Panda {
return buf.toString();
}
async getType() {
let buf = await this.vendorRequest('getType', {
const buf = await this.vendorRequest('getType', {
request: 0xc1,
value: 0,
index: 0
Expand Down Expand Up @@ -184,7 +184,7 @@ export default class Panda {
// i/o wrappers
async vendorRequest (event, controlParams, length) {
try {
let result = await this.device.vendorRequest(controlParams, length);
const result = await this.device.vendorRequest(controlParams, length);

return result.data;
} catch (err) {
Expand All @@ -197,7 +197,7 @@ export default class Panda {
message = Buffer.from([]);
}
try {
let result = await this.device.vendorWrite(controlParams, message);
const result = await this.device.vendorWrite(controlParams, message);

return result.data;
} catch (err) {
Expand Down Expand Up @@ -238,7 +238,7 @@ export default class Panda {
this.flushEvent();

if (this.needsFlush && this.messageQueue.length) {
let messageQueue = this.messageQueue;
const messageQueue = this.messageQueue;
this.messageQueue = [];
this.needsFlush = false;
MessageEvent.broadcast(this, messageQueue);
Expand All @@ -265,9 +265,9 @@ export default class Panda {
this.isReading = true;

for (let i = 0; i < MAX_MESSAGE_QUEUE; ++i) {
let data = await this.device.nextMessage();
let receiptTime = now() / 1000
let canMessages = unpackCAN(data);
const data = await this.device.nextMessage();
const receiptTime = now() / 1000
const canMessages = unpackCAN(data);
if (!canMessages.length) {
await wait(1);
continue;
Expand Down

0 comments on commit 64b35e3

Please sign in to comment.