Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
Serializer.prototype.byteArrayToString = function (bytes/* : Uint8Array */) {
return utf8.read(bytes, 0, bytes.length)
}
const getNextRecord = (buffer: Uint8Array): Uint8Array | null => {
const newlineIndex = buffer.indexOf(10);
if (newlineIndex === -1) {
// this commonly happens if we have consumed all records and the
// buffer is now empty.
return null;
}
const start = newlineIndex + 1;
const recordLength = parseInt(utf8.read(buffer, 0, newlineIndex), 10);
return buffer.length >= recordLength + start
? buffer.slice(start, start + recordLength)
: null;
};