Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
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);
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;
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
function StreamProvider(){
Duplex.call(this, {
objectMode: true,
})
this._payloads = {}
}
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);
function DuplexStream(override) {
this.options = xtend(options, override);
Duplex.call(this, this.options);
}
function RPCStream() {
if (!this instanceof RPCStream)
return new RPCStream();
Duplex.call(this, { objectMode: true });
this._lastSequence = 0;
this._pending = {};
}
util.inherits(RPCStream, Duplex);
function Decompressor(options) {
Duplex.call(this, {
readableObjectMode: true
});
this._decoder = decoder.create();
this._table = table.create(options.table);
}
inherits(Decompressor, Duplex);
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);