Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
function rleDecode(buf, offset, datalen, bitWidth) {
var header = varint.decode(buf, offset);
var count = header >>> 1;
datalen -= varint.decode.bytes;
if (header & 1) { // Bit packed
console.log('read ' + (count * 8) + ' bit packed values');
} else { // RLE
console.log('read ' + count + ' RLE values');
console.log('remain ' + datalen + ' bytes');
}
}
return function(obj, buf, offset) {
var len = varint.decode(buf, offset);
offset += varint.decode.bytesRead;
var end = offset + len;
obj[key] = [];
while (offset < end) {
var next = {};
obj[key].push(next);
var itemLen = varint.decode(buf, offset);
offset += varint.decode.bytesRead;
offset = dec(next, buf, offset, offset, offset+itemLen);
}
return offset;
};
};
nameStorage.read(0, st.size, (err, buf) => {
if (err) return cb(err, null)
let len = 0
try {
len = varint.decode(buf, 0)
} catch (err) {
return cb(null, null)
}
const offset = varint.decode.bytes
if (offset + len !== buf.length) return cb(null, null)
const name = buf.slice(offset)
return cb(null, name)
})
})
function decodeVarint (buf, offset) {
try {
return varint.decode(buf, offset)
} catch (err) {
return -1
}
}
function unpackArray (buf) {
var offset = 0
var arr = []
while (offset < buf.length) {
arr.push(varint.decode(buf, offset))
offset += varint.decode.bytes
}
return arr
}
exports.varint = function(buff) {
return varint.decode(buff);
};
exports.varint = function(buff) {
return varint.decode(buff);
};
exports.varint = function(buff) {
return varint.decode(buff);
};