Add util.js featuring bufferToString()

This commit is contained in:
László Monda
2016-09-27 16:08:00 +02:00
parent fcd1bc4f58
commit 67695151aa
2 changed files with 15 additions and 1 deletions

13
usb/util.js Executable file
View File

@@ -0,0 +1,13 @@
exports = module.exports = {
bufferToString: function(buffer) {
var str = '';
for (var i = 0; i < buffer.length; i++) {
var hex = buffer[i].toString(16) + ' ';
if (hex.length <= 2) {
hex = '0' + hex;
}
str += hex;
};
return str;
}
}