Ues ES6 features all across util.js

This commit is contained in:
László Monda
2017-01-15 01:03:29 +01:00
parent 199030effb
commit 0e59a99e36
+12 -12
View File
@@ -1,14 +1,14 @@
var usb = require('usb'); let usb = require('usb');
exports = module.exports = { exports = module.exports = {
getUsbEndpoints: function() { getUsbEndpoints: () => {
var vid = 0x16d3; let vid = 0x16d3;
var pid = 0x05ea; let pid = 0x05ea;
var device = usb.findByIds(vid, pid); let device = usb.findByIds(vid, pid);
device.open(); device.open();
var usbInterface = device.interface(0); let usbInterface = device.interface(0);
// https://github.com/tessel/node-usb/issues/147 // https://github.com/tessel/node-usb/issues/147
// The function 'isKernelDriverActive' is not available on Windows and not even needed. // The function 'isKernelDriverActive' is not available on Windows and not even needed.
@@ -17,15 +17,15 @@ exports = module.exports = {
} }
usbInterface.claim(); usbInterface.claim();
var endpointIn = usbInterface.endpoints[0]; let endpointIn = usbInterface.endpoints[0];
var endpointOut = usbInterface.endpoints[1]; let endpointOut = usbInterface.endpoints[1];
return [endpointIn, endpointOut]; return [endpointIn, endpointOut];
}, },
bufferToString: function(buffer) { bufferToString: buffer => {
var str = ''; let str = '';
for (var i = 0; i < buffer.length; i++) { for (let i = 0; i < buffer.length; i++) {
var hex = buffer[i].toString(16) + ' '; let hex = buffer[i].toString(16) + ' ';
if (hex.length <= 2) { if (hex.length <= 2) {
hex = '0' + hex; hex = '0' + hex;
} }