How to use the bodec.toString function in bodec

To help you get started, we’ve selected a few bodec 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 mjackson / bufferedstream / index.js View on Github external
function flush(stream) {
  if (!stream._chunks)
    return;

  var chunk;
  while (chunk = stream._chunks.shift()) {
    stream.size -= chunk.length;

    if (stream.encoding) {
      stream.emit('data', bodec.toString(chunk, stream.encoding));
    } else {
      stream.emit('data', chunk);
    }

    // If the stream was paused in a data event handler, break.
    if (stream.paused)
      break;
  }

  if (stream.ended) {
    if (!stream.paused) {
      stream._chunks = null;
      stream.emit('end');
    }
  } else if (stream._wasFull && !stream.full) {
    stream._wasFull = false;
github mjackson / bufferedstream / tests / helpers.js View on Github external
function stringifyData(data) {
  return bodec.toString(bodec.join(data));
}
github mjackson / mach / build / npm / Message.js View on Github external
return this.bufferContent(maxLength).then(function (chunk) {
      return bodec.toString(chunk, encoding);
    });
  }),
github mjackson / mach / modules / Message.js View on Github external
return this.bufferContent(maxLength).then(function (chunk) {
      return bodec.toString(chunk, encoding);
    });
  }),