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;
};
Serializer.prototype.stringToByteArray = function (msg/* : string */) {
const bytes = new Uint8Array(utf8.length(msg))
utf8.write(msg, bytes, 0)
return bytes
}
Serializer.prototype.stringToByteArray = function (msg/* : string */) {
const bytes = new Uint8Array(utf8.length(msg))
utf8.write(msg, bytes, 0)
return bytes
}