How to use the readable-stream.Readable.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 stdlib-js / stdlib / lib / node_modules / @stdlib / random / streams / erlang / lib / main.js View on Github external
if ( !isPositiveInteger( k ) ) {
		throw new TypeError( 'invalid argument. First argument must be a positive integer. Value: `'+k+'`.' );
	}
	if ( !isPositiveNumber( lambda ) ) {
		throw new TypeError( 'invalid argument. Second argument must be a positive number. Value: `'+lambda+'`.' );
	}
	opts = copy( DEFAULTS );
	if ( arguments.length > 2 ) {
		err = validate( opts, options );
		if ( err ) {
			throw err;
		}
	}
	// Make the stream a readable stream:
	debug( 'Creating a readable stream configured with the following options: %s.', JSON.stringify( opts ) );
	Readable.call( this, opts );

	// Destruction state:
	setNonEnumerable( this, '_destroyed', false );

	// Cache whether the stream is operating in object mode:
	setNonEnumerableReadOnly( this, '_objectMode', opts.objectMode );

	// Cache the separator:
	setNonEnumerableReadOnly( this, '_sep', opts.sep );

	// Cache the total number of iterations:
	setNonEnumerableReadOnly( this, '_iter', opts.iter );

	// Cache the number of iterations after which to emit the underlying PRNG state:
	setNonEnumerableReadOnly( this, '_siter', opts.siter );
github stdlib-js / stdlib / lib / node_modules / @stdlib / streams / node / from-array / lib / main.js View on Github external
}
		return new ArrayStream( src );
	}
	if ( !isArrayLikeObject( src ) ) {
		throw new TypeError( 'invalid argument. First argument must be an array-like object. Value: `' + src + '`.' );
	}
	opts = copy( DEFAULTS );
	if ( arguments.length > 1 ) {
		err = validate( opts, options );
		if ( err ) {
			throw err;
		}
	}
	// Make the stream a readable stream:
	debug( 'Creating a readable stream configured with the following options: %s.', JSON.stringify( opts ) );
	Readable.call( this, opts );

	// Destruction state:
	setNonEnumerable( this, '_destroyed', false );

	// Cache whether the stream is operating in object mode:
	setNonEnumerableReadOnly( this, '_objectMode', opts.objectMode );

	// Cache the separator:
	setNonEnumerableReadOnly( this, '_sep', opts.sep );

	// Define the serialization function:
	setNonEnumerableReadOnly( this, '_serialize', opts.serialize || JSON.stringify );

	// Cache the data source:
	setNonEnumerableReadOnly( this, '_src', src );
github stdlib-js / stdlib / lib / node_modules / @stdlib / random / streams / bernoulli / lib / main.js View on Github external
}
		return new RandomStream( p );
	}
	if ( !isProbability( p ) ) {
		throw new TypeError( 'invalid argument. First argument must be a probability. Value: `'+p+'`.' );
	}
	opts = copy( DEFAULTS );
	if ( arguments.length > 1 ) {
		err = validate( opts, options );
		if ( err ) {
			throw err;
		}
	}
	// Make the stream a readable stream:
	debug( 'Creating a readable stream configured with the following options: %s.', JSON.stringify( opts ) );
	Readable.call( this, opts );

	// Destruction state:
	setNonEnumerable( this, '_destroyed', false );

	// Cache whether the stream is operating in object mode:
	setNonEnumerableReadOnly( this, '_objectMode', opts.objectMode );

	// Cache the separator:
	setNonEnumerableReadOnly( this, '_sep', opts.sep );

	// Cache the total number of iterations:
	setNonEnumerableReadOnly( this, '_iter', opts.iter );

	// Cache the number of iterations after which to emit the underlying PRNG state:
	setNonEnumerableReadOnly( this, '_siter', opts.siter );
github stdlib-js / stdlib / lib / node_modules / @stdlib / random / streams / cauchy / lib / main.js View on Github external
if ( !isNumber( x0 ) || isnan( x0 ) ) {
		throw new TypeError( 'invalid argument. First argument must be a number primitive and not `NaN`. Value: `'+x0+'`.' );
	}
	if ( !isPositiveNumber( gamma ) ) {
		throw new TypeError( 'invalid argument. Second argument must be a positive number. Value: `'+gamma+'`.' );
	}
	opts = copy( DEFAULTS );
	if ( arguments.length > 2 ) {
		err = validate( opts, options );
		if ( err ) {
			throw err;
		}
	}
	// Make the stream a readable stream:
	debug( 'Creating a readable stream configured with the following options: %s.', JSON.stringify( opts ) );
	Readable.call( this, opts );

	// Destruction state:
	setNonEnumerable( this, '_destroyed', false );

	// Cache whether the stream is operating in object mode:
	setNonEnumerableReadOnly( this, '_objectMode', opts.objectMode );

	// Cache the separator:
	setNonEnumerableReadOnly( this, '_sep', opts.sep );

	// Cache the total number of iterations:
	setNonEnumerableReadOnly( this, '_iter', opts.iter );

	// Cache the number of iterations after which to emit the underlying PRNG state:
	setNonEnumerableReadOnly( this, '_siter', opts.siter );
github stdlib-js / stdlib / lib / node_modules / @stdlib / random / streams / minstd / lib / main.js View on Github external
if ( !( this instanceof RandomStream ) ) {
		if ( arguments.length > 0 ) {
			return new RandomStream( options );
		}
		return new RandomStream();
	}
	opts = copy( DEFAULTS );
	if ( arguments.length > 0 ) {
		err = validate( opts, options );
		if ( err ) {
			throw err;
		}
	}
	// Make the stream a readable stream:
	debug( 'Creating a readable stream configured with the following options: %s.', JSON.stringify( opts ) );
	Readable.call( this, opts );

	// Destruction state:
	setNonEnumerable( this, '_destroyed', false );

	// Cache whether the stream is operating in object mode:
	setNonEnumerableReadOnly( this, '_objectMode', opts.objectMode );

	// Cache the separator:
	setNonEnumerableReadOnly( this, '_sep', opts.sep );

	// Cache the total number of iterations:
	setNonEnumerableReadOnly( this, '_iter', opts.iter );

	// Cache the number of iterations after which to emit the underlying PRNG state:
	setNonEnumerableReadOnly( this, '_siter', opts.siter );
github trygve-lie / twitter-stream-api / lib / main.js View on Github external
objectMode = param1;
    }

    if (utils.isObject(param1)) {
        options = param1;
    }

    if (utils.isObject(param2)) {
        options = param2;
    }

    this.connection = new Connection(keys, options);
    this.streamEndpoint = 'statuses/filter';
    this.streamParams = null;
    
    Readable.call(this, {objectMode: objectMode});
    this.connection.on('data', function (obj) {
        if (!self.push(objectMode ? obj : JSON.stringify(obj))) {
            self.connection.destroy();
        }
    });



    // Reconnect strategy - TCP/IP level network errors
    // 250 ms linearly up to 16 seconds

    var backoffNetworkError = new Backoff(new LinStrategy({
        initialDelay: 250,
        maxDelay: 16000
    }))
    .on('backoff', helpers.onBackoff.bind(this))
github stdlib-js / stdlib / lib / node_modules / @stdlib / streams / node / from-constant / lib / main.js View on Github external
}
	if ( opts.objectMode === false ) {
		if ( isString( value ) ) {
			value = string2buffer( value );
		} else if ( isBuffer( value ) ) { // NOTE: order matters here. We want the `isBuffer` check BEFORE the `isUint8Array` check!!
			// Nothing to do, as value is already a buffer...
		} else if ( isUint8Array( value ) ) {
			// Convert to a `Buffer` object to provide backward compatibility with older Node.js versions...
			value = arraybuffer2buffer( value.buffer, value.byteOffset, value.length ); // eslint-disable-line max-len
		} else {
			throw new TypeError( 'invalid argument. In binary mode, a provided value must be a string, Buffer, or Uint8Array. Value: `' + value + '`.' );
		}
	}
	// Make the stream a readable stream:
	debug( 'Creating a readable stream configured with the following options: %s.', JSON.stringify( opts ) );
	Readable.call( this, opts );

	// Destruction state:
	setNonEnumerable( this, '_destroyed', false );

	// Cache whether the stream is operating in object mode:
	setNonEnumerableReadOnly( this, '_objectMode', opts.objectMode );

	// Cache the separator:
	setNonEnumerableReadOnly( this, '_sep', string2buffer( opts.sep ) );

	// Cache the total number of iterations:
	setNonEnumerableReadOnly( this, '_iter', opts.iter );

	// Cache the value to stream:
	setNonEnumerableReadOnly( this, '_value', value );
github prabhu / mongots / dist / lib / cursor.js View on Github external
function Cursor(opts) {
        Readable.call(this, { objectMode: true, highWaterMark: 0 });
        var self = this;
        this._opts = opts;
        var onserver = this._opts.onserver;
        this._get = thunky(function (cb) {
            onserver(function (err, server) {
                if (err)
                    return cb(err);
                cb(null, server.cursor(self._opts.fullCollectionName, {
                    find: self._opts.fullCollectionName,
                    query: self._opts.query || {},
                    fields: self._opts.projection,
                    sort: self._opts.sort,
                    skip: self._opts.skip,
                    limit: self._opts.limit,
                    batchSize: self._opts.batchSize,
                    explain: self._opts.explain,
github sx1989827 / DOClever / Desktop / node_modules / tar-stream / pack.js View on Github external
var Pack = function (opts) {
  if (!(this instanceof Pack)) return new Pack(opts)
  Readable.call(this, opts)

  this._drain = noop
  this._finalized = false
  this._finalizing = false
  this._destroyed = false
  this._stream = null
}
github RainBlock / merkle-patricia-tree / src / checkpoint-interface.js View on Github external
function ScratchReadStream (trie) {
  this.trie = trie
  this.next = null
  Readable.call(this, {
    objectMode: true
  })
}