How to use the stream.PassThrough function in stream

To help you get started, we’ve selected a few stream 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 othiym23 / uncurled / index.js View on Github external
function send(options, data, encoding, contentType) {
  options.headers  = {'Content-Type' : contentType};
  options.encoding = encoding;

  return _send(options, data, new PassThrough()).pipe(request(options, handler));
}
github krakenjs / spud / lib / transcoder.js View on Github external
function startDeserialize(source, sourceType, cb) {
    var callback = once(cb);
    if (!source) {
        return callback(new Error("no source to deserialize"));
    } else if (Buffer.isBuffer(source)) {
        var temp = source;
        source = new stream.PassThrough();
        source.end(temp);
    } else if (typeof source === 'string') {
        source = fs.createReadStream(source);
    }

    source.on('error', callback);

    deserialize(source, sourceType, callback);
}
github OwenRay / Remote-MediaServer / backend / modules / sharing / MediaFetcher.js View on Github external
startStream(offset) {
    this.offset = this.hashes.findIndex(h => offset <= h.offset + h.size);
    Log.debug('starting to download from offset: ', offset, `${this.offset}/${this.hashes.length - 1}`);
    this.skipBytes = offset - this.hashes[this.offset].offset;
    this.output = new PassThrough();
    this.output.on('close', this.end.bind(this));
    this.downloadNext();
    return this.output;
  }

stream

Node.js streams in the browser

MIT
Latest version published 6 months ago

Package Health Score

72 / 100
Full package analysis