How to use @protobufjs/utf8 - 4 common examples

To help you get started, we’ve selected a few @protobufjs/utf8 examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github brave / sync / lib / serializer.js View on Github external
Serializer.prototype.byteArrayToString = function (bytes/* : Uint8Array */) {
  return utf8.read(bytes, 0, bytes.length)
}
github dcos / dcos-ui / src / js / core / MesosStream.ts View on Github external
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;
};
github brave / sync / lib / serializer.js View on Github external
Serializer.prototype.stringToByteArray = function (msg/* : string */) {
  const bytes = new Uint8Array(utf8.length(msg))
  utf8.write(msg, bytes, 0)
  return bytes
}
github brave / sync / lib / serializer.js View on Github external
Serializer.prototype.stringToByteArray = function (msg/* : string */) {
  const bytes = new Uint8Array(utf8.length(msg))
  utf8.write(msg, bytes, 0)
  return bytes
}

@protobufjs/utf8

A minimal UTF8 implementation for number arrays.

BSD-3-Clause
Latest version published 8 years ago

Package Health Score

82 / 100
Full package analysis

Similar packages