module.exports = read var MSB = 0x80 , REST = 0x7F function read(buf, offset) { var res = 0 , offset = offset || 0 , shift = 0 , counter = offset , b do { b = buf[counter++] res += shift < 28 ? (b & REST) << shift : (b & REST) * Math.pow(2, shift) shift += 7 } while (b >= MSB) if(b === undefined) { read.bytesRead = 0 res = undefined } else read.bytesRead = counter - offset return res }