index.js
function _attachStreamMethod(qb) {
  /**
   * Create the stream function for a pass through to the datastax driver,
   * all callbacks are defaulted to lodash#noop if not declared.
   *
   * @param `{Object} options` optional argument passed to datastax driver upon query execution
   * @param `{Object} cbs` =>
   * {
     *  readable: function() {},
     *  end: function() {},
     *  error: function(err) {}
     * }
   * @returns {Client|exports|module.exports}
   */
  qb.stream = function (options, cbs) {

    var _options = _.isObject(cbs) ? options : {}
      , _cbs = _.isObject(cbs) ? cbs : options
      , onReadable = _cbs.readable || _.noop
      , onEnd = _cbs.end || _.noop
      , onError = _cbs.error || _.noop;

    if (cassandra !== null && cassandra.connected) {
      var cql = qb.cql();
      cassandra.stream(cql, qb.bindings(), _options)
        .on("readable", onReadable)
        .on("end", onEnd)
        .on("error", onError);
    }
    else {
      console.error("Cassandra client is not initialized.");
      onError(new Error("Cassandra client is not initialized."));
    }

    // maintain chain
    return qb;
  };
}
function _attachStreamMethod(qb) {
  /**
   * Create the stream function for a pass through to the datastax driver,
   * all callbacks are defaulted to lodash#noop if not declared.
   *
   * @param `{Object} options` optional argument passed to datastax driver upon query execution
   * @param `{Object} cbs` =>
   * {
     *  readable: function() {},
     *  end: function() {},
     *  error: function(err) {}
     * }
   * @returns {Client|exports|module.exports}
   */
  qb.stream = function (options, cbs) {

    var _options = _.isObject(cbs) ? options : {}
      , _cbs = _.isObject(cbs) ? cbs : options
      , onReadable = _cbs.readable || _.noop
      , onEnd = _cbs.end || _.noop
      , onError = _cbs.error || _.noop;

    if (cassandra !== null && cassandra.connected) {
      var cql = qb.cql();
      cassandra.stream(cql, qb.bindings(), _options)
        .on("readable", onReadable)
        .on("end", onEnd)
        .on("error", onError);
    }
    else {
      console.error("Cassandra client is not initialized.");
      onError(new Error("Cassandra client is not initialized."));
    }

    // maintain chain
    return qb;
  };
}
function _attachStreamMethod ( qb ) { /**
   * Create the stream function for a pass through to the datastax driver,
   * all callbacks are defaulted to lodash#noop if not declared.
   *
   * @param `{Object} options` optional argument passed to datastax driver upon query execution
   * @param `{Object} cbs` =>
   * {
     *  readable: function() {},
     *  end: function() {},
     *  error: function(err) {}
     * }
   * @returns {Client|exports|module.exports}
   */ qb . stream = function ( options , cbs ) { var _options = _ . isObject ( cbs ) ? options : { } , _cbs = _ . isObject ( cbs ) ? cbs : options , onReadable = _cbs . readable || _ . noop , onEnd = _cbs . end || _ . noop , onError = _cbs . error || _ . noop ; if ( cassandra !== null && cassandra . connected ) { var cql = qb . cql ( ) ; cassandra . stream ( cql , qb . bindings ( ) , _options ) . on ( "readable" , onReadable ) . on ( "end" , onEnd ) . on ( "error" , onError ) ; } else { console . error ( "Cassandra client is not initialized." ) ; onError ( new Error ( "Cassandra client is not initialized." ) ) ; } // maintain chain return qb ; } ; }
hooks the 'stream' cassandra client method to our query builder object
@param qb
@private
hooks the stream cassandra client method to our query builder object