How to use the readable-stream.Duplex.call function in readable-stream

To help you get started, we’ve selected a few readable-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 nfroidure / bufferstreams / src / index.js View on Github external
return new BufferStream(options, cb);
  }

  // Cast args
  if (options instanceof Function) {
    cb = options;
    options = {};
  }
  options = options || {};
  if (!(cb instanceof Function)) {
    throw new Error('The given callback must be a function.');
  }
  _this.__objectMode = options.objectMode;

  // Parent constructor
  Duplex.call(_this, options);

  // Keep a reference to the callback
  _this._cb = cb;

  // Add a finished flag
  _this._bufferStreamFinished = false;

  // Internal buffer
  _this._bufferStreamBuffer = [];

  // Internal logic
  function _bufferStreamCallbackWrapper(err) {
    const buffer = options.objectMode
      ? _this._bufferStreamBuffer
      : Buffer.concat(_this._bufferStreamBuffer);
github olebedev / swarm / swarm-syncable / src / OpStream.js View on Github external
function OpStream (stream, options) {
    if (!stream || !stream.on) {
        throw new Error('no stream provided');
    }
    Duplex.call(this, {objectMode: true});
    this.stream = stream;
    this.options = options = options || {};
    this.pending_s = []; // FIXME this is not our business

    // Local session/database/timestamp
    // this.ssn_id = options.ssn_id || null;
    // this.db_id = options.db_id || null;
    // this.stamp = options.stamp || '0';
    // Peer session/database/timestamp
    // this.peer_hs = null;
    this.source = options.source || null;
    this.mute = false;

    // this.peer_ssn_id = null; // TODO tidy this up
    // this.peer_db_id = null;  // (store hs, add accessor methods)
    // this.peer_stamp = null;
github sx1989827 / DOClever / Desktop / node_modules / spdy-transport / lib / spdy-transport / stream.js View on Github external
function Stream (connection, options) {
  Duplex.call(this)

  var connectionState = connection._spdyState

  var state = {}
  this._spdyState = state

  this.id = options.id
  this.method = options.method
  this.path = options.path
  this.host = options.host
  this.headers = options.headers || {}
  this.connection = connection
  this.parent = options.parent || null

  state.socket = null
  state.protocol = connectionState.protocol
github brave / ethereum-remote-client / app / scripts / lib / stream-provider.js View on Github external
function StreamProvider(){
  Duplex.call(this, {
    objectMode: true,
  })

  this._payloads = {}
}
github buggerjs / bugger-v8-client / lib / streams / eternal.js View on Github external
function EternalSocket() {
  if (!(this instanceof EternalSocket)) {
    var args = [null].concat([].slice.call(arguments));
    var Bound = EternalSocket.bind.apply(EternalSocket, args);
    return new Bound();
  }

  this._connectArgs = [].slice.apply(arguments);
  this._socket = null;

  Duplex.call(this);
}
util.inherits(EternalSocket, Duplex);
github mixu / pipe-iterators / lib / duplex.js View on Github external
function DuplexStream(override) {
    this.options = xtend(options, override);
    Duplex.call(this, this.options);
  }
github buggerjs / bugger-v8-client / lib / streams / rpc.js View on Github external
function RPCStream() {
  if (!this instanceof RPCStream)
    return new RPCStream();

  Duplex.call(this, { objectMode: true });

  this._lastSequence = 0;
  this._pending = {};
}
util.inherits(RPCStream, Duplex);
github sx1989827 / DOClever / Desktop / node_modules / hpack.js / lib / hpack / decompressor.js View on Github external
function Decompressor(options) {
  Duplex.call(this, {
    readableObjectMode: true
  });

  this._decoder = decoder.create();
  this._table = table.create(options.table);
}
inherits(Decompressor, Duplex);
github gameclosure / devkit-core / src / build / util / stream-wrap.js View on Github external
function WrapStreams() {
  Duplex.call(this, {objectMode: true});

  var onData = function (chunk, encoding) {
    this.push(chunk, encoding);
  }.bind(this);

  var onEnd = function () {
    this.push(null);
  }.bind(this);

  this.on('finish', function () {
    this._firstStream.end();
  });

  this.once('pipe', function () {
    this._lastStream.on('data', onData);
    this._lastStream.on('end', onEnd);